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

Rob Allen:
Route specific configuration in Slim
Dec 13, 2018 @ 10:46:41

Rob Allen has posted a new tutorial to his site sharing how you can set up route specific configurations in Slim by setting it as a part of the route definition.

A friend emailed me recently asking about route specific configuration in Slim. He wants to be able to set properties when creating the route that he can pick up when the route is matched. The way to do this is using route arguments. I’ve written about route arguments before in the context of setting default values for a route parameter, but you can also use them to set new data for use later.

In this post, I’m going to look at how to use them for configuration data, such as setting required ACL permissions for routes.

He includes code snippets showing how to set the per-route data and how to access it from inside of the request handling via the Request instance. He shows an example of this both in the basic route definition and in middleware.

tagged: route configuration specific tutorial middleware

Link: https://akrabat.com/route-specific-configuration-in-slim/

Laravel News:
Speeding Up PHP with OPcache in Docker
Dec 05, 2018 @ 10:16:51

The Laravel News site has a new tutorial posted showing how to speed up your PHP execution when developing with Docker by making use of the OPCache functionality.

If you’re on Docker for Mac or Docker for Windows, you might see some noticeable slowness and time to the first byte (TTFB) depending on your application’s setup. One of the most important things you can do to improve performance is enabling the OPCache module (regardless of the development environment). There are other things like volume caching (if possible), but OPcache is a win that you want in any environment you’re running PHP applications.

The tutorial starts by sharing a basic Opcache configuration, setting values for timestamp validation, memory consumption, and fast shutdown. These values are static and not very flexible so they change things up by making them able to be set as a part of the Docker build process. The post includes the changes you'll need to make to your Docker configuration to make this setup work in two ways: either copying the file in on build or making use of environment variables to set the configuration options at runtime.

tagged: opcache docker tutorial speed performance configuration

Link: https://laravel-news.com/php-opcache-docker

Tomas Votruba:
How to Manage Configuration in Symfony without Bundle, Extension, and Configuration?
Nov 30, 2018 @ 12:55:07

In this new post to his site Tomas Votruba shows how to configure a Symfony application without using the bundle or extension configurations.

Symfony Flex is moving towards of bundle-less applications. That doesn't mean you should create a monolith code in /src as fast as possible, but rather control everything via .yaml and .env files. It's takes few steps to remove extension and move to import of services.yaml.

But how would you approach a simple task as setup a account number parameter?

For those not familiar with "no-bundle applications" in Symfony, he starts with a link to the SymfonyCast course listing out the main points. Following this he covers what changes in the service registration and what changes in the configuration (with code examples). He then provides some options including keeping the extension, setting the parameter manually and binding the parameter, favoring the last two on his list as more maintainable.

tagged: tutorial symfony configuration bundle extension management

Link: https://www.tomasvotruba.cz/blog/2018/11/29/how-to-manage-configuration-in-symfony-without-bundle-extension-and-configuraiton/

Jason McCreary:
Installing Apache, PHP, and MySQL on macOS Mojave
Nov 30, 2018 @ 11:21:05

Jason McCreary has provided a tutorial on his site today for all of the OS X Mojave users out there about how to install Apache, PHP and MySQL on macOS with the latest operating system changes. This is an update of his previous post covering the same installation on OSX Sierra.

I am aware of the web server software available for macOS, notably MAMP, as well as package managers like brew. These get you started quickly. But they forego the learning experience and, as most developers report, can become difficult to manage.

The thing is macOS runs atop UNIX. So most UNIX software installs easily on macOS. Furthermore, Apache and PHP come preinstalled with macOS. To create a local web server, all you need to do is configure Apache and install MySQL.

He walks you through the full process to get everything up and running:

  • testing to ensure Apache can be started (it comes installed by default)
  • changing the configuration to enable PHP
  • making a phpinfo page in your DocumentRoot to test that PHP is working
  • downloading and installing MySQL
  • configuration changes required to connect PHP and MySQL

He also includes an example of additional changes such as enabling mod_rewrite and a link to a tutorial about setting up virtual hosts on your local machine.

tagged: installation osx mojave update tutorial mysql apache configuration

Link: https://jason.pureconcepts.net/2018/11/install-apache-php-mysql-mac-os-x-mojave/

Symfony Blog:
Improvements to the Handling of .env Files for all Symfony Versions
Nov 20, 2018 @ 13:28:28

On the Symfony blog they've made a post about a change in all Symfony versions around how .env files are handled and what prompted the change.

When Symfony 4.0 was released, the .env file was introduced as a way to set environment variables. The core of the system has not changed. But, thanks to recent updates to some core Symfony recipes, .env loading has some new features that can be enjoyed on any Symfony Flex project!

If you have an existing Symfony app (started before today), your app does not require any changes to keep working. But, if/when you are ready to take advantage of these improvements, you will need to make a few small updates.

The post outlines what changed exactly including the removal of the .env.dist, allowing a .env.local to override the settings and that the .env file is now pulled in for testing. The final point is the main reasoning for the changes to make testing much easier when it relies on these environment variable values. It doesn't require any changes to your current application but can be optionally implemented to take advantage of these updates.

tagged: symfony improvement environment file configuration change env

Link: https://symfony.com/blog/improvements-to-the-handling-of-env-files-for-all-symfony-versions

Tomas Votruba:
Do you Autowire Services in Symfony? You can Autowire Parameters Too
Nov 07, 2018 @ 11:20:14

In a new post to his site Tomas Votruba looks at autowiring Symfony services and parameters to make it even easier to integrate services into your application.

I love how Symfony caught up late autowiring integration in since Symfony 2.8. Then set a trend in Symfony 3.3 with service autoregistration.

That opens new possibilities to almost config-less registration, doesn't it?

He first looks at some of the "old" configuration handling, defining the services manually in the YAML configuration along with their arguments. He shows how this evolves with the addition of autowiring and autodiscovery, minus the parameters. He continues on to show how to integrate parameter handling into the services configuration via the bind option. He also shows how to improve this and use autowired parameters and call them directly in the constructor of your class and let the DI container do the rest.

tagged: symfony autowire service parameter tutorial example yaml configuration

Link: https://www.tomasvotruba.cz/blog/2018/11/05/do-you-autowire-services-in-symfony-you-can-autowire-parameters-too/

RIPSTech.com:
WordPress Configuration Cheat Sheet
Nov 02, 2018 @ 12:23:19

For the WordPress users out there, the RIPSTech.com blog has posted an invaluable "cheat sheet" sharing details on securing your configuration to prevent exploits and other issues down the line.

WordPress is the most frequently installed web application in the world. The system is operated not only by experienced developers but also by beginners. In this blog post, we summarize what to look out for when configuring your WordPress installation’s security.

In our series about misconfigurations of PHP frameworks, we have investigated Symfony, a very versatile and modular framework. Due to the enormous distribution and the multitude of plugins, WordPress is also a very popular target for attackers. This cheat sheet focuses on the wp-config.php file and highlights important settings to check when configuring your secure WordPress installation.

Suggestions made in the guide cover values involving: debugging, database credentials, keys/salts, database repair, external requests and many more. The post provides examples for each of the settings and a recommended value to make it easy to drop in the changes and harden your WordPress installation.

tagged: security configuration wordpress cheatsheet settings tutorial

Link: https://blog.ripstech.com/2018/wordpress-configuration-cheat-sheet/

Laravel News:
Minimalist Sublime Text 3 Setup for PHP
Nov 02, 2018 @ 11:44:03

On the Laravel News site today Paul Redmond has shared about his own preferred development environment, making use of the Sublime Text 3 editor, and how he has it set up for his PHP development.

While many developers are flocking to IDEs and other hybrids like Visual Studio Code, I’ve found myself trying to create a minimalist Sublime Text 3 setup. I am a minimalist at heart, and I like both my physical environment and virtual environment to be as minimal and tidy as possible.

I want to present to you the minimalist Sublime Text 3 setup that I’ve landed on, but still feel like I have most everything I need to be productive.

He breaks down the article into a few different sections with details for each:

  • Built-In Features
  • PHP Companion
  • CLI Access
  • Plugins
  • Snippets
  • Code Linting

For each item in the list he provides example configuration additions, command line calls, code, and links to the tools he uses.

tagged: minimalist sublimetext3 setup configuration tutorial development

Link: https://laravel-news.com/minimalist-sublime-text-3-setup-for-php

Tomas Votruba:
Painful Experience over Solutions: Extend Configuration in Easy Admin Bundle
Aug 21, 2018 @ 10:15:19

In a new post to his site Tomas Votruba talks about the benefits of writing SOLID code and uses a more real-world example rather than talking about SOLID in theory.

Use SOLID to write Clean Code... Are you tired of theoretical post about how to do achieve some therm? So am I. Instead, let's dive into real problems I came across while coding and let the code speak the theory between lines.

Today we try to add own config option to YAML of Easy Admin Bundle (without pull-request to the package).

In his example, he works with a training platform he's creating for use by the Pehapkari community that makes use of the EasyAdminBundle. He starts off with what he's trying to accomplish ("the need"): being able to change only certain pieces of information. He then walks through the process he followed to customize the form and "getting creative" to be able to add items to the form without having to add each individually. He walks about his "wandering" through the code to look for a solution and, ultimately, how he found the answer using another configuration file.

tagged: solid design configuration easyadminbundle symfony tutorial

Link: https://www.tomasvotruba.cz/blog/2018/08/20/painful-experience-over-solutions-extend-configuratin-in-easy-admin-bundle-with-collector/

Sameer Borate:
Using the TOML configuration format in your applications
Aug 01, 2018 @ 12:54:59

In this new post to his site Sameer Borate looks at using the TOML configuration file format in a PHP application.

As any one who has programmed knows about configuration files. Configuration files are mostly text files used to configure the parameters and initial settings for computer programs – mostly user applications, operating system settings.

[...] In this post we will look into parsing TOML files in PHP. TOML is a configuration file format that is intended to be easy to read due to its obvious semantics and is designed to map unambiguously to a dictionary data structure. “TOML”, the name, is an acronym for “Tom’s Obvious, Minimal Language” referring to its creator Tom Preston-Werner.

He starts with an example of a configuration file in the TOML format and, following the installation/used of the yosymfony/toml library, the result of it being parsed. He also includes an example of using the same library to build out a TOML configuration and dump it to a string for output.

tagged: toml configuration file format introduction tutorial package

Link: https://www.codediesel.com/data/using-the-toml-configuration-format-in-your-applications/