For the record:
If you ever encounter this error while upgrading Apache webserver 2.2 to 2.4:
Unknown Authz provider: from
Then you probably made a mistake replacing:
allow from all
Require all granted
And just replaced allow with Require and not the complete directive, like:
Require from all
Then its time for a double facepalm :)
I recently switched from PHPStorm to IntelliJ Ultimate because of some Java. But still i am working a lot on PHP and symfony projects.
One thing i usually do on symfony projects in PHPStorm is to edit the “Directories” in the settings to avoid having results from var/cache or var/logs in the search results.
Also it slows down the search which i heavily use. So i exlude all folders that should not be searched because they are cache files or are redundant in some other way.
Continue reading “Directories settings in PHPStorm and IntelliJ Ultimate”
When working with APIs you sometimes cant use the live API in the tests.
Because you dont own the API, dont want to spam, cant create entities for testing or various other reasons.
Then you need to mock the API and deliever responses from fixtures.
Though there is this term of “Don’t mock what you don’t own” we will mock the API because we dont own it. :)
https://github.com/julienfalque/http-mock is a nice library which helps a lot when mocking an API.
And when your client is using Guzzle there is also a Guzzle handler for HttpMock that makes integration easy.
How does this work?
Continue reading “mocking APIs with Guzzle”
From time to time i receive this error while running the official mysql image in docker:
An exception occured in driver: SQLSTATE[HY000]  Host ‘172.17.0.5’ is
not allowed to connect to this MySQL server
The reason for this is not quite clear yet but i usually resolve it like described here.
Note that all data stored in the project will be lost!
So this error is quite annyoing but luckily i work on fixtures so i can restore data easily.
These steps let me connect to the mysql container again, at least.
Continue reading “Not allowed to connect to Mysql error in docker”
Since version 3.1 there is a Cache component with a PSR-6 implementation integrated in Symfony.
So we do not need to add a 3rd party lib as Doctrine Cache anymore when we need caching these days.
Doctrine Cache does the job but by implementing a standard the Symfony Cache seems to have another advantage besides its delievered anyway. So i checked it out.
Documentation is still a bit sparse and the best resource so far is this blogpost:
I wont go into detail on how you use the Cache but rather how you integrate it with Redis, which is my favourite Cache backend.
Continue reading “Symfony Cache Component with SncRedisBundle”
Sometimes you just want to check a SilverStripe version, module or theme fast and dont want to setup the whole stack.
Then simply use PHPs built-in webserver to serve your SilverStripe site.
php -S localhost:8000 ./framework/main.php
Now you can call http://localhost:8000 to check your SilverStripe website.
Or, a bit more verbose, use https://github.com/assertchris/silverstripe-serve
which is a nice wrapper around this.
Continue reading “SilverStripe with php built-in server”
I just released a twig extension for https://github.com/sebastianbergmann/money
The money libary contains a money represention based on the currency’s smallest unit to provide a more accurate handling. See the libary’s readme for more information.
Although the v1.x version of Money brings a Formatter the Twig extension uses its own, which is better suited and more flexible.
Continue reading “Twig Extension for Money value object”
Some news from the Superleansilexplate:
- v3 now uses symfony3 components
Silex 1.3 supports symfony3 so lets use it :)
Note: as symfony3 doesnt support php5.4 anymore, we dont either!
- new ConsoleServiceProvider
the one from knplabs that was used before seems to be unmaintained and wasnt matching the dependencies anymore.
So i decided to take it over and renew it a bit. Check it out!
- Docker support
I started to use Docker as dev enviroment for my projects, so i added dev & prod Docker support.
For the sake of simplicity it uses a single container with Apache and PHP7.
If you have Docker and docker-compose on your machine just spin it up with
docker-compose up and check on localhost:8088.
Continue reading “Superleansilexplate Update v3”
For creating PHP packages several best practices has been established, like composer support (ofc) and putting the package on packagist, travis integration, directory organisation, tests, documentation and so on.
For further information i recommend these slides https://laravel-news.com/2015/08/hannes-van-de-vreken-package-development-slides/ which describe the situation very well.
And as we are all lazy, we like generators that scaffold a basic php package layout and luckily there are several out there.
They all differ a bit, so pick your favorite.
Continue reading “PHP package generators”
Using your forks of certain packages with composer is actually pretty easy:
Add the repo of the fork to the repositories block of your composer.json, you might need to change the version to f.e dev-master and thats it. Great. Actually.
But there are some traps, especially when you are mentally already weekend bound:
When working in a team, take care that you dont add your fork as a private repo.
This happens when you use the @ notation like ‘firstname.lastname@example.org‘. Its tempting because it will be the clone url on github when you are logged in, which is very likely.
If you do so your team mates will get errors like this:
Failed to execute git clone --no-checkout 'email@example.com:ivoba/SomeBundle.git' [...] && git remote add composer 'firstname.lastname@example.org:ivoba/SomeBundle.git' && git fetch composer
Continue reading “Using forks with composer – late night edition”