Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Matt Stauffer:
What packages do you install on every Laravel application you create?
Jul 19, 2017 @ 12:29:44

On his site Matt Stauffer has a post that asks the readers about the packages they always install for their Laravel applications (and not necessarily just Laravel related packages either).

In preparation for my upcoming [talk](http://customlaravel.com/) at [Laracon 2017](https://laracon.us/), which I'm titling "Custom Laravel," I [asked a quick question](https://twitter.com/stauffermatt/status/885666786036899840) on Twitter to my followers. [...] I wanted to know for my talk, but I was also just curious for my own purposes. Are there any packages I should check out that everyone else already knows about? Here's what I found, in order of the number of recommendations I received...

While most of the packages in his lists (unanimous support, well-loved, etc) are Laravel specific, mostly because of his audience on Twitter, there are some that weren't. These included:

You can check out his full listing in the remainder of the post and a link to another listing from Mike Erickson asking the same kind of question.

tagged: package install laravel application community feedback list

Link: https://mattstauffer.co/blog/what-packages-do-you-install-on-every-laravel-application-you-create

Freek Van der Herten:
Optimize images in Laravel apps
Jul 17, 2017 @ 09:48:01

In a continuation of his previous post about an image optimization package for PHP Freek Van der Herten covers some refactoring and advancements they've made to the package to make it even easier to use.

A while ago we released image-optimizer. In short this package can make all kinds of images smaller by stripping out metadata and applying a little bit of compression. Read this blogpost to learn more about it. Although it’s pretty easy to work with the package, we felt that we could deliver a more seamless experience in Laravel apps. That’s why we created our newly released laravel-image-optimizer package.

The package uses a bunch of binaries to optimize images. To learn which ones and how to install them, head over to the optimization tools section in the readme of the underlying image-optimizer package. That readme also contains info on <a href="https://github.com/spatie/image-optimizer#which-tools-will-do-what>what these tools will do to your images.

He then includes some code examples putting this new version of the package to work with a Laravel-based application. The examples include replacing the image with an optimized one, saving the optimized one to a new path and resize all images in a request. There's also an example configuration included showing the options you can set to customize your site's image optimization even more.

tagged: optimize image laravel application package tutorial

Link: https://murze.be/2017/07/optimize-images-laravel-apps/

Laravel News:
A guide for prioritizing application errors
Jul 03, 2017 @ 10:17:26

The Laravel News site has posted a tutorial that offers some advice on how to prioritize fixing bugs and errors in your applications.

One major problem is that prioritizing errors isn’t always clear. Figuring out how much negative impact a bug is really causing is important to answer because not all bugs are worth fixing.

That’s why having a solid workflow in place for prioritizing bugs is so important. In order to confidently allocate your engineering resources on bug fixes and feature building, you need to understand the scope of each application error, and its impact on your customers. Then you can definitively say particular bugs are high enough priority that they should be scheduled into a sprint alongside your work on building new features.

The article is then broken down into a few different sections, each with a few points underneath:

  • Get setup with smart error reporting from the start
  • Focus your error inbox to keep it actionable
  • Prioritize the most relevant errors first
  • Prioritize errors by moving them into your debugging workflow

The post is sponsored by Bugsnag so there's some of the content that suggests using their service but the advice is sound for any kind of error handling workflow.

tagged: priority error tracking application fixes workflow tips

Link: https://laravel-news.com/prioritize-application-errors

Olav van Schie:
Make your Laravel App Fly with PHP OPcache
Jun 14, 2017 @ 10:16:21

On his Medium site Olav van Schie shows you how to "make your Laravel app fly" with the help of OPcache. While OPcache isn't something that's specific to Laravel, he does include a package near the end that makes it easier to use it with the caching built into "artisan".

Every time you execute a PHP script, the script needs to be compiled to byte code. OPcache leverages a cache for this bytecode, so the next time the same script is requested, it doesn’t have to recompile it. This can save some precious execution time, and thus make your app faster (and maybe save some server costs).

He starts with a brief overview of OPcache and the main benefit it provides. He also shares some benchmarks he performed on a Digital Ocean server based on the results of performance testing the default Laravel "welcome" page. He then shows how to check and be sure it's installed and enabled on your PHP installation and some good default settings to configure in your php.ini. The post wraps up mentioning the package that helps integrate it with the Laravel application and the command required to clear out the OPcache on deploy.

tagged: laravel application opcache caching opcode performance tutorial

Link: https://medium.com/appstract/make-your-laravel-app-fly-with-php-opcache-9948db2a5f93

Stephan Hochdöfer:
Dockerizing GitLab Review Apps
Jun 07, 2017 @ 10:28:15

On the BitExpert blog Stephan Hochdöfer has written up a post showing how to "Dockerize" GitLab review apps to create a consistent platform for these self-contained environments.

Last year GitLab introduced the Review Apps feature. Review Apps are app environments that are created dynamically every time you push a new branch up to GitLab. As a bonus point the app environments are automatically deleted when the branch is deleted. Since we moved to using docker for quite a few of our projects I was keen on figuring out how to combine Docker and the GitLab Review Apps functionality as the documentation only mentions NGINX as a way to run Review Apps. As it turns out, it is rather simple to deploy docker containers as a Review App.

He describes the environment he needs and which tools he'll be using to perform the build of the environments. He then defines the sample GitLab configuration file including the "build" stage. He briefly explains the steps this follows then shows the configuration for the "deploy" step, grabbing the latest image from his Docker repo and running it. He ends the post with an "undeploy" stage that removes the Docker build automatically when the environment is no longer needed.

tagged: gitlab review application apps tutorial docker deploy undeploy

Link: https://blog.bitexpert.de/blog/dockerizing-gitlab-review-apps/

SitePoint PHP Blog:
How to Build a Twitter Follower-Farmer Detection App with RestDB
May 31, 2017 @ 12:17:03

The SitePoint PHP blog has a tutorial posted for the Twitter users out there showing you how to create a "follower-farmer" detection tool that will scan your account for followers that track your account and then soon after unfollow as a means of gaming the follower system.

Are you active on Twitter? If so, do you often wonder why some accounts seem to follow you only to unfollow you moments (or days) later? It’s probably not something you said – they’re just follower farming.

[...] Follower farming is a known social media hack taking advantage of people who “#followback” as soon as someone follows them. [...] In this post, we’ll build an app which lets you log in via Twitter, grabs your followers, and compares the last fetched follower list with a refreshed list in order to identify the new unfollowers and calculate the duration of their follow, potentially auto-identifying the farmers.

They use a Homestead VM and a fresh Laravel installation to create their application. It makes use of the Socialite package to connect to Twitter using your application's client ID and secret. The application then makes use of the guzzlehttp/oauth-subscriber package to connect to the Twitter API and get a list of current followers. The post also includes the code to create a "FollowerServiceProvider" to make it simpler to get the follower information. He then shows how to set up the RestDB account and push the follower content out to it for storage. The tutorial wraps up with the code required to analyze the followers against "unfollowers" and report back the results.

tagged: twitter follower farmer detect application laravel tutorial

Link: https://www.sitepoint.com/how-to-build-a-twitter-follower-farmer-detection-app-with-restdb/

SitePoint PHP Blog:
Web App Performance Testing with Siege – Plan, Test, Learn
May 30, 2017 @ 12:27:36

The SitePoint PHP blog has a tutorial posted that wants to help you test you application and get the best performance from it. The tutorial introduces you to Siege, a performance testing tool that includes benchmarking functionality.

Almost anyone can build an app locally, deploy it to a server, and proudly show it to your friends. I hope you’ve already done all of this, and your project went viral, so you’re obviously here because you want to learn how to make sure your app is ready for some high traffic.

[...] In this article, designed to speed this [learning] process up, I will cover the basic concepts of testing the app (regression, load, and stress testing) with Siege</a and some tips and tricks I like to use when I’m testing my own web apps.

The tutorial starts with an overview of the types of testing and a few tips for making your testing successful and effective. Then, using a sample Symfony demo application, they show how to make basic requests using Siege and what kind of data the results report. With the basics out of the way, they then cover more advanced topics like concurrency and doing the actual performance testing. Based on the results, they see that caching content could definitely help and, after enabling that, see the numbers go down dramatically. The post ends with a look at other testing tools and some of the things you'd need to plan out when using Siege against your application to get the most meaningful results.

tagged: application performance testing siege tool tutorial

Link: https://www.sitepoint.com/web-app-performance-testing-siege-plan-test-learn/

thePHP.cc:
Testing Keeps Me From Getting Things Done
May 25, 2017 @ 09:52:29

On thePHP.cc site they have a new post that tries to refute a common claim from developers when it comes to testing: testing keeps me from getting things done. The post is a response to an email to the group about testing asking where the real value is in applications versus libraries/tools.

To successfully develop software means to work target-oriented. These targets should be derived from acceptance criteria that are reconciled with the business. Without clear targets – we mean at a task level, not project or annual targets – the developer runs the risk of getting lost in work. Most importantly, he does not know when he is done with a task.

It is prudent to document and verify acceptance criteria through automated tests. One way or another, the targets have to be defined before production code gets written. This is test-driven development, whether you want to call it that or not.

The response goes on to talk about how, with tests written after the code has already been written (legacy code), it's not always clear what the original intent was resulting in lost context. It also compares two of the main types of testing - integration and unit - and the place each has in an overall testing strategy.

tagged: testing unittest reply integration opinion application

Link: https://thephp.cc/news/2017/05/testing-keeps-me-from-getting-things-done

Symfony Blog:
Preparing your Applications for PHP 7 with Symfony Polyfills
May 19, 2017 @ 11:07:50

The Symfony blog has posted an article showing you how to prepare your applications for a migration to PHP 7 with the help of various polyfill libraries. These libraries make it possible to use PHP 7 functionality in non-PHP 7 applications if the function in use isn't defined.

According to the May 2017 PHP Stats, 53% of PHP developers use PHP 7.0 or 7.1, but only 10% of Composer packages require PHP 7.0 or higher. In fact, 1 in 4 packages still require PHP 5.3, which is used by less than 1% of developers.

[...] Upgrading your development machines is usually a simple task, but upgrading the rest of the infrastructure (servers, tools, etc.) usually requires more resources. This is where Symfony Polyfills can help you preparing the code of your application for PHP 7.

The article briefly explains what polyfills are and how to load in the current Symfony set via a Composer install. There've provided functionality for PHP versions 5.4 through 5.6 as well as PHP 7.0 and 7.1 to ensure you have the most up to date functionality at your fingertips.

tagged: php7 application symfony polyfill library functionality composer tutorial

Link: http://symfony.com/blog/preparing-your-applications-for-php-7-with-symfony-polyfills

SitePoint PHP Blog:
The Ultimate Guide to Deploying PHP Apps in the Cloud
May 12, 2017 @ 12:18:59

On the SitePoint PHP blog author Prosper Otemuyiwa shares what they call the ultimate guide to deploying PHP apps in the cloud with examples for Heroku, Google Cloud, IBM BlueMix, Microsoft Azure, Amazon Web Services and Laravel Forge.

There is a popular mantra amongst developers that goes like this write, test and deploy. In this tutorial, I’ll show you how to deploy your PHP apps to different cloud server platforms such as Google Cloud, Microsoft Azure, Heroku, IBM Bluemix, and others.

Cloud servers are basically virtual servers that run within a cloud computing environment. There are various benefits to hosting and deploying your applications in the cloud. [...] In fact, many companies have moved their infrastructure to the cloud in order to reduce cost and complexity. It’s a great option for small, mid-sized, and enterprise scale businesses. If you write a lot of tutorials and do POCs (Proof-of-concepts) like me, it’s also a great choice for you!

He starts off by covering the technologies that will be involved in each deploy: Linux, Apache, MySQL and of course PHP. Then, for each of the platforms previously mentioned, he goes through the setup and configuration of the same functionality. Most include screenshots of the UI in the service setting up the account and application. He also links to two tools that can make it easier to deploy your actual application to these newly configured cloud instances: Envoyer and Deployer.

tagged: guide deploy application cloud google bluemix azure aws forge

Link: https://www.sitepoint.com/ultimate-guide-deploying-php-apps-cloud/