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

SitePoint PHP Blog:
How Can I Use Laravel Envoyer or Deployer with SemaphoreCI?
Apr 04, 2017 @ 11:16:59

The SitePoint PHP blog has posted a tutorial showing you how to use Laravel Envoyer or Deployer with SemaphoreCI and popular continuous integration service.

Test automation, continuous integration, and continuous delivery are quite widespread in the community now. This brought to life multiple services trying to make the process more enjoyable and less overwhelming for developers, so they can focus on delivering software instead of building/configuring tools to do that. One of those services is SemaphoreCI.

In this article, we’re going to cover how to use our own deploy scripts and tools to continue the deployment process after a successful test.

They then show you how to create the Deployer configuration file to make the deployment to the remote Digital Ocean servers of a Laravel-based application. Most of the steps are in copying the local files up to the remote server as a "staging" environment. He then hops back over to the SemaphoreCI service to create the deployment plan for the project using the "deployer.phar" command line tool, linking it to the push of new code. They then move to the same process just defined via the Laravel Envoyer tool and a similar command line call.

tagged: laravel envoyer deployer semaphoreci tutorial setup configure plan

Link: https://www.sitepoint.com/how-can-i-use-laravel-envoyer-or-deployer-with-semaphoreci/

Laravel News:
Laravel Forge API
Feb 28, 2017 @ 14:36:37

The Laravel News site has posted an official announcement about the Forge API being released for public use. Forge is a service that makes it easier to set up and configuration servers by taking care of a lot of the details for you.

Laravel Forge just announced it’s first official API that allows you to create and interact with your servers and sites.

This was a highly requested feature and the API includes support for all the features Forge provides including Servers, Services, Daemons, Firewall Rules, Sites, SSL, and more.

The post includes how to get started with the API, where to get your API token and how to send it over for authorization handling. You can find more information about the Forge API in the documentation on the Forge site.

tagged: laravel forge api release announcement server setup configure

Link: https://laravel-news.com/laravel-forge-api

Zend Framework Blog:
PHP and SQL Server for Linux
Feb 15, 2017 @ 11:21:52

The Zend Framework blog has a new post from Enrico Zimuel talking about the use of SQL Server for Linux from inside a PHP-based application. This makes use of the preview release of SQL Server for Linux directly from Microsoft.

This week we tested the public preview of Microsoft SQL Server for Linux using PHP 7 with our component zendframework/zend-db.

Microsoft announced the availability of a public preview of SQL Server for Linux on the 16th of November, 2016. [...] Moreover, the performance of the new DBMS seems to be very impressive. Microsoft published a case study with 1.2 million requests per second with In-Memory OLTP on a single commodity server.

The tutorial shows you how to get the SQL Server software installed on a Ubuntu-based system and install it via apt-get. They also show how to install the command line tool for SQL Server and get the msodbcsql driver needed to make the connection. Finally they show how to set up the driver with PHP 7 (via PDO) and running the Zend/Db integration tests using a Vagrant-created and configured VM instance.

tagged: sqlserver linux tutorial php7 install configure vagrant microsoft

Link: https://framework.zend.com/blog/2017-02-14-php-sql-server-linux.html

Freek Van der Herten:
Using Varnish on a Laravel Forge provisioned server
Jan 05, 2017 @ 14:19:15

Freek Van der Herten has a post to his site showing you how to set up Varnish with a Laravel Forge server. Forge is a service that makes it simpler to set up and manage servers and the applications installed without having to mess with the details yourself.

For a project we’re working on at Spatie we’re expecting high traffic. That’s why we spent some time researching how to improve the request speed of a Laravel application and the amount of requests a single server can handle. There are many strategies and services you can use to speed up a site. In our specific project one of the things we settled on is Varnish. In this post I’d like to share how to set up Varnish on a Forge provisioned server.

He gives a high level overview of what Varnish is and what benefit it provides to your application (complete with illustrations) and includes a link to a presentation introducing Varnish to PHP developers. Then he moves on to installing Varnish on the server, updating the VCL configuration file and opening a port for you to use when connecting to the Varnish service. He shows the difference in the response headers when Varnish handles the response and the updates you'll need to make to get your Laravel application to play nicely with Varnish with this package.

He ends the post with examples of how to test the performance difference and some final steps to update the config and have it run on port 80 instead of the default 6081.

tagged: laravel forge varnish provision server tutorial setup configure performance

Link: https://murze.be/2017/01/varnish-on-a-laravel-forge-server/

Laravel News:
Installing Bourbon and Neat with Laravel Elixir
Oct 06, 2016 @ 10:25:09

On the Laravel News site a tutorial has been published showing you how to install Bourbon and Neat with Laravel's "elixir" functionality (a wrapper around the popular Gulp installation tool for Javascript and CSS library handling.

Laravel Elixir is a wrapper that simplifies working with Gulp, it makes compiling, concating, minifying and versioning your JavaScript and CSS files very fluent and easy.

Because many projects using Bootstrap, when you start a new Laravel project, you will find that it is included by default as a basic starting point, but Laravel does not dictate which JavaScript or CSS frameworks you should use. One alternative is Bourbon and Neat created by thoughtbot.

Bourbon is a mixin library for Sass and Neat is a Bourbon addon for creating semantic grids. In this tutorial let’s take a look at how to setup these tools with Laravel Elixir.

They start with a brief overview of the Bourbon tool, showing how it helps to reduce the amount of duplicate code in your source files. There's also a bit about Neat, a responsive grid library that makes it easier to keep your layout "clean and semantic". With those defined they get into the installation of these two packages with two different approaches:

  • First installing Bourbon/Neat via npm then importing them in the SASS config
  • Or installing them via npm, edit the Gulp configuration then import them relatively

With either of these methods in place the Elixir tool can then run the compilation right alongside the other sources and push the resulting CSS out the other side including the Bourbon and Neat functionality.

tagged: laravel install configure elixir bourbon neat semantic clean tutorial

Link: https://laravel-news.com/2016/10/installing-bourbon-neat-laravel-elixir/

Theo Tzaferis:
Let CodeSniffer inspect your code in PhpStorm
Sep 15, 2016 @ 10:56:32

In a quick new post to his site Theo Tzaferis shows you how to set up PHPStorm and PHP_CodeSniffer to perform automatic inspection of your PHP code's syntax.

Some time ago I wrote an article on how to format your code automatically in PhpStorm to be conform the PSR standards. In this article I want to show you how you can enable inspections in PhpStorm which throws a warning if you have code which is not PSR, e.g.
  • Whitespace at the end of line
  • No newline at the end of file
  • No newline between namespace and use statements
  • etc…
This is pretty easy. We will use squizlabs/PHP_CodeSniffer from Github.

I’m doing this on an Ubuntu machine, but it should work the same in OS X (no idea about Windows).

He then provides the (*nix-centric) instructions on getting the two tools up and playing happily together. Fortunately PHPStorm comes with handy built-in support for PHP_CodeSniffer, basically only requiring you to install phpcs and point it to the right location. The rest is handled by the IDE when you enable the automatic evaluation.

tagged: phpstorm codesniffer tutorial setup configure automatic inspection

Link: http://tzfrs.de/2016/09/let-codesniffer-inspect-your-code-in-phpstorm/

SitePoint PHP Blog:
Up and Running with the Fastest PHP Framework on PHP7 in 5 Mins
Aug 24, 2016 @ 11:22:46

On the SitePoint PHP blog editor Bruno Skvorc has posted a tutorial helping you get up and running with PHP 7 and Phalcon in five minutes on a Homestead Improved virtual machine.

You may remember our past infatuation with Phalcon, the fastest PHP framework.

In this post, we’ll go through the process of getting it up and running in 5 minutes on one of our <a href="http://www.sitepoint.com/quick-tip-get-homestead-vagrant-vm-running/>Homestead Improved instances. If you’re not interested in why or what Phalcon is, just skip ahead to “Setting it up”.

He starts with a brief recap of what the Phalcon framework is (including Zephir), some history behind it and the latest advancement around the framework: LTS support for v3.0. The tutorial then gets into the setup and configuration of the VM along with PHP 7 and the latest stable version of Phalcon. He then uses the sample application provided by Phalcon and getting it boostrapped and running.

tagged: phalcon php7 tutorial demo homesteadimproved vm setup configure extension

Link: https://www.sitepoint.com/up-and-running-with-the-fastest-php-framework-on-php7-in-5-mins/

Symfony Finland:
Consider Docker for your Symfony projects
Aug 15, 2016 @ 11:24:35

On the Symfony Finland site there's a post that makes a recommendation for your Symfony framework based projects: give Docker a try to make setup and maintenance simpler.

During the first half of 2016 the web development community has talked about Docker quite a bit. The technology has been around since 2013, but during the last few months it has matured and started being adopted for mainstream web development. Docker is a great fit for Symfony projects too.

[...] Docker takes an approach where it wraps a piece of software into something known as a container. These containers are shipped complete with the application code, a runtime, system tools and libraries. Containers are thus guaranteed to always run the same, but can share files and networking with the host and other containers.

They then talk about how this "containerized" setup can be used to your advantage, making it simpler to get a Symfony application up and running with a few commands. The post then gets into an example setup of a Symfony Docker environment complete with Nginx, Varnish and PHP-FPM installed and linked. There's also setup for MySQL and Redis rounding out the data storage side. A quick "docker-composer up" command and, if all goes as expected, the environment is set up and waiting for your application.

tagged: symfony finland docker project tutorial setup configure

Link: https://www.symfony.fi/entry/consider-docker-for-your-symfony-projects

Matt Stauffer:
Introducing Laravel Echo: An In-Depth Walk-Through
Jun 17, 2016 @ 12:11:02

Matt Stauffer has a new post to his site where he's put together an in-depth look at Laravel Echo, a feature included in newer versions of the framework that makes it easy to integrate websockets into your Laravel-based application.

A few weeks ago, Taylor Otwell introduced another branded product within the Laravel line: Laravel Echo. So far, the only coverage it's gotten has been his Laracasts video intro, but I recently wrote it up for my book and wanted to share that with you. What follows is an excerpt from Laravel: Up and Running, heavily modified to make sense in a blog format.

He then gets into what Echo is and the different pieces that make it up: updates to the Laravel broadcast system and a new Javascript package. He suggests some places where using Echo makes sense and how to set up a simple broadcast event in your application (non-Echo to start). This makes use of the Pusher service for real-time event broadcasting. With that in place, he helps you install the Echo dependencies and integrating messages from both public and private channels. He also includes a bit of code at the end to exclude the message from broadcasting to the current user if you ever find a need for it.

tagged: laravel echo indepth tutorial setup configure pusher javascript

Link: https://mattstauffer.co/blog/introducing-laravel-echo

Understanding Laravel Middleware
Jun 16, 2016 @ 13:20:48

The Scotch.io site has posted a tutorial that aims to help you understand middleware in Laravel applications - how they work and how to create ones based on your custom needs.

HTTP Middlewares provide a convenient mechanism for filtering HTTP requests entering your application. Laravel, for example, has a middleware for verifying a user's authentication.

These are some cases where I have had to resort to using middleware. There are many more cases where you would like to use a middleware. [...] By the end of this article, you should be able to create a middleware, registers it and use it in your projects. We will be illustrating the creation till usage of middlewares by creating one of our own. Our middleware will enable maintenance either site-wide or on some routes.

They start by creating a middleware (theirs is DownForMaintenance) and how to register it with Laravel as a valid middleware option. By default they will execute with every request but you can narrow them down to only happening on certain routes (examples included). There's also mentions of middleware parameters, grouping middleware and deferring the response return until after other code is executed.

tagged: laravel middleware introduction tutorial create execute configure

Link: https://scotch.io/tutorials/understanding-laravel-middleware