I have made this project (
Docker For LAMP) publically available on Github, under the MIT license.
The target user group is php developers who want or need a simple, minimal (yet very current) LAMP development environment. I want this to be friendly to new developers, and a useful alternative to localhost environments like xamp, mamp or wamp.
Ideally it offers the type of convenience and isolation of a vagrant lamp environment except with orchestrated containers.
Continue reading "docker4lamp - A LAMP Docker development environment"
Certainly the most convenient way to develop a Symfony 5.x app is to use the symfony server. Eventually however, you may have to deploy the application. For a number of years nginx with php-fpm was the preference for many sysadmins seeking to wring the maximum performance out of a webserver that also has to run php scripts, but there are now simple ways of configuring apache to use php-fpm while achieving comparable performance to nginx.
For example a vhost setting like this one is possible:
<
VirtualHost *:
80>
SetEnv ENVIRONMENT
"dev" <
FilesMatch \.php$>
SetHandler proxy:fcgi://php:
9000 # for Unix sockets, Apache 2.4.10 or higher </
FilesMatch>
# Proxy .php requests to port 9000 of the php-fpm container DocumentRoot /usr/local/apache2/cms/public
ServerName cms.mydev.local
ServerAdmin [email protected] <
Directory /usr/local/apache2/cms/public>
DirectoryIndex index.php index.html
Options Indexes FollowSymLinks AllowOverride All Require all granted
</
Directory>
# Send apache logs to stdout and stderr CustomLog /proc/self/fd/
1 common
ErrorLog /proc/self/fd/
2</
VirtualHost>
Continue reading "Symfony 5.2 and Apache 2.4"
Having backed Fabien Potencier's "
Symfony 5: The Fast Track" book on Kickstarter, I received the book a few weeks ago, and had a chance over the weekend to start reading it.
As a Macbook/OSX user, his recommended environment includes a current locally installed version of PHP with a number of php extension libraries. You also need installation of the php standard composer tool, as well as docker. As I have a Macbook running OSX Mojave, I had to take a number of steps to be able to get started following the book and getting a working installation of the guestbook project using the book's recipe. Here's what I did:
Continue reading "Symfony 5: The Fast Track book and installing a local PHP version that works!"
So you have a private Bitbucket Repo and you want to utilize it in your project
composer.json. You may find that when you run the composer install you get an error pulling your private Bitbucket repo with messages about Oauth failure that may include "
Invalid OAuth consumer provided"
Continue reading "Composer install of Private Bitbucket VCS "aka" 'Invalid OAuth consumer provided'"
So you are installing a modern version of php using one of the alternative repositories, and suddenly you are confronted with a confusing choice. You want support for mysql (mysqli or PDO-mysql) in your php program. But which one to choose?
First off,
you should probably be using PDO. It's just a cleaner database interface when compared to mysqli, and also tends to be the supported option if you're using an ORM like Doctrine2.
But you probably have found that installing the PDO package doesn't get you support for MySQL.
So what are these 2 packages? Well let's see what yum under Centos shows us, once we've setup webtatic as a repo:
* webtatic: us-east.repo.webtatic.com
==============================================
php56w-mysql.x86_64 : A module for PHP applications that use MySQL databases
php56w-mysqlnd.x86_64 : A module for PHP applications that use MySQL databases
In short, the mysql extension aka the mysql library is to quote Oracle/mysql
... a general-purpose client library
named libmysql.
This was the original php approach to supporting mysql. MySQL provided a client api library, and using that c library, a php extension was created that depends upon libmysql implementing the famous mysql_ functions that allowed php to talk to mysql.
The mysqlnd package (where nd stands for "native driver") is the fruit of a project to make mysql work optimally in the php language. Again to quote the mysql site:
The mysqlnd library is highly optimized for and tightly integrated into PHP. The MySQL Client Library cannot offer the same optimizations because it is a general-purpose client library.
The mysqlnd library is using PHP internal C infrastructure for seamless integration into PHP. In addition, it is using PHP memory management, PHP Streams (I/O abstraction) and PHP string handling routines. The use of PHP memory management by mysqlnd allows, for example, memory savings by using read-only variables (copy on write) and makes mysqlnd apply to PHP memory limits.
On top of these benefits are
a number of interesting enhancements and support for plugins that might be of specific interest to you as a developer or sysadmin.
In general nothing should break in your code as the api should work the same under mysqlnd as it did with the old mysql library.
Conclusion
In summary, you want to use mysqlnd now and in the future.
A PHP block is started with the tag
<?php. However, there is also an alternative known as a "
short open tag" which is to only use
<?
The problem with using short open tags is that they conflict with xml parsers and for that reason, support for short open tags has to be enabled. By default, it's disabled and enabling deprecated features may be impossible if hosts don't allow it.
Every so often you may come upon a code base that was written using short open tags.
Often people are first confronted with this problem when they have a legacy code base, and either move it to a new server or upgrade php only to find that the site is spewing errors and no longer functional. In a worse case scenario portions of your php code will be plainly visible to end users due to the fact that the php parser is no longer parsing those blocks and simply returning them as html text.
There are a number of different approaches you can take to solve this problem. First you can
turn on the support for short open tags, but as I mentioned previously, this is not recommended.
Continue reading "Fixing PHP short open tags"