be.dev

Web development blog by Philipp Rieber

Creating a PSR-7 Guzzle Request object with form-data

Uploading files with Guzzle 6 using a multipart/form-data request is pretty straightforward. But creating a request object with a file upload independently from the actual sending process turns out to not be that obvious.

Read more.

Using Doctrine Naming Strategies in Symfony

Frequently, I’m stumbling upon very verbose Doctrine metadata definitions that translate each and every table and column definition from camelCase names to names separated by underscores, e.g. firstName to first_name. But did you know that can simply get rid of all this noise by implementing a Doctrine naming strategy?

Read more.

Integrating PHP Coding Standards Fixer with PhpStorm

Fixing coding standard issue individually is very tedious, e.g after running a static code analysis tool or after being declined by a code sniffer pre-commit hook. To ease these kind of tasks you may consider using SensioLabs’s awesome little CLI tool called PHP Coding Standards Fixer.

Read more.

Optimize Debugging in a Symfony application

When debugging a Symfony application with Xdebug you might not only want to step through your own custom code, but also through the Symfony code itself. As a lot of Symfony’s core code is aggregated and optimized into a single file at app/bootstrap.php.cache for performance reasons, you will not feel very comfortable reading non-highlighted, non-indented code of classes from multiple namespaces all assembled in the same file. And this is even true for the dev environment, where debugging usually happens. But some simple tweaks in the front controller will allow you to step through the original Symfony code if and only if a debug session was initialized.

Read more.

Run phpspec when saving files with gulp and PhpStorm

In our weekly Code Kata at work, we’re exercising TDD using phpspec. TDD means switching between coding and running the tests all the time, may causing cramps by abuse of Cmd+Tab. So why not automate the test runs whenever a source file changes and show a decent notification about success or failure?

Read more.