Category Archives: PHP Development

The thin line between an Invocation

PHP language changes and until we understand them. Did this caught your attention? The release of PHP 8.1 is quite some days ago, like November the year before last year, and when I first learned about first class callable syntax … Continue reading

Posted in PHP Development, Pressed, The Know Your Language Department, Uncategorized | Tagged , , | Leave a comment

Speedpills 4 Linting PHP Files in Parallel

Quite some time ago I’ve already written about linting PHP files in the shell / build. Even though parallel linting is fine, when the code-base is growing larger and larger, the build becomes slower and slower. A slow build sucks. … Continue reading

Posted in Hakre's Tips, PHP Development, PHP Development, Pressed, Scripts, Tools, Uncategorized | Tagged , , , , , | 1 Comment

Using Assertions with (Legacy) PHP Code

While it was not much advised to use assertions (the assert PHP language construct) prior to PHP 7 due to the fact that it actually eval’ed a string’ed code, these days are gone. This is probably a lesser known fact with … Continue reading

Posted in Developing, Hakre's Tips, PHP Development, PHP Development, Pressed, The Know Your Language Department, Tools | Tagged , , , , , , , | Leave a comment

Lazy Loading in PHP Object Composition

When it comes to nicely performing PHP scripts (yes in PHP these are all scripts as PHP code is run-time) there is a nice addition since PHP 7 named the Null coalescing operator which plays very well with the basic nature … Continue reading

Posted in Hakre's Tips, PHP Development, PHP Development, Pressed, The Know Your Language Department, Tools | Tagged , | Leave a comment

History of the PHP date timezone settings warning

Now with the newborn elefant PHP 7 in the herd, there is a lift on the date timezone settings warning: it has just been removed. That means, it’s now that you need to take care in the server’s configuration that … Continue reading

Posted in Pressed, The Know Your Language Department | Tagged , , , , | Leave a comment

Linting PHP Files in Parallel on Travis

With PHP 7 around the corner here is a small tip how you can at least lint the code in your project to be PHP 7 syntax compatible. That allows you to easier obtain forward-compatible PHP code with ease. So … Continue reading

Posted in Hakre's Tips, PHP Development, Pressed, Tools | Tagged , , , , , , , , | Leave a comment

The SimpleXMLElement Magic Wonder World in PHP

PHP’s Simplexml ships with a lot of magic to simplify access to an XML documents element and attribute node values. Some criticize this and suggest to use the DOM library instead. The DOM library on the other hand, even it … Continue reading

Posted in Developing, Hakre's Tips, PHP Development, Pressed, The Know Your Language Department, Uncategorized | Tagged , , , , | Leave a comment

Composer Clear Cache

It’s one of the best kept secrets of popular PHP dependency manager Composer: How to flush composers cache. You normally don’t need it, however if you create some composer.json and you want to put it to a test, this can … Continue reading

Posted in Developing, Hakre's Tips, PHP Development | Tagged , , , , , | 5 Comments

PHP turtles – Turtles all the way down

Some nice line-up for the know your language department: PHP turtles – Turtles all the way down.

Posted in Linked, PHP Development, Pressed, The Know Your Language Department | Tagged | Leave a comment

XPath Null Byte Injection in PHP

Back in July this year, in Mitigating XPath Injection Attacks in PHP I was writing about how to properly quote a string in PHP’s Xpath 1.0. The code presented there was based on the assumption that the resulting expression is … Continue reading

Posted in Hakre's Tips, PHP Development, Pressed, Surviving the Internet | Tagged , , , , , , , | Leave a comment

Mitigating XPath Injection Attacks in PHP

PHP has two libxml based extensions that allow to execute XPath 1.0 expressions: DOM (by the DOMXPath class) and SimpleXML (with its xpath() method). Both extensions are prone to XPath Injection Attacks, a common attack form. Albeit all this, and … Continue reading

Posted in Hakre's Tips, PHP Development, Pressed, Surviving the Internet | Tagged , , , , , , , | 1 Comment

SimpleXML and JSON Encode in PHP – Part III and End

The previous two parts (Part I; Part II) did outline PHP’s standard behaviour when JSON encoding a SimpleXMLElement with json_encode(). As outlined this does not always fits the encoding needs and for some potential problems some workarounds have been showed. … Continue reading

Posted in Developing, PHP Development, PHP Development, Pressed, Tools | Tagged , , , , , | 4 Comments

SimpleXML and JSON Encode in PHP – Part II

In the previous post (Part I) I was giving a little overview for common woes turning a SimpleXMLElement into JSON when XML structural information is available that JSON is not capable to encode easily. The explanations given there were intended … Continue reading

Posted in Developing, PHP Development, PHP Development, Pressed, Tools | Tagged , , , , , | 2 Comments

SimpleXML and JSON Encode in PHP – Part I

With SimpleXMLElement it is often easy and looks like a very quick way to turn some XML into JSON. But not everything in PHP that has an easy interface works out of the box. In this three part series I’ll … Continue reading

Posted in Developing, PHP Development, PHP Development, Pressed, Tools | Tagged , , , , , | Leave a comment

The Greatest PHP Value

Just two days ago I asked a PHP-quiz-question in the chatroom on Stackoverflow, something along the lines: PHP: Which one is greatest? PHP has a comparison operator to compare if one value is greater than the other (>). Which one … Continue reading

Posted in Developing, PHP Development, Pressed, The Know Your Language Department | Tagged , , , , , | Leave a comment

Late Static Bindings in PHP Callbacks

No idea if this is ever useful, but just found this not documented in the PHP manual so far (and the Callbacks entry looks already chaotic so I don’t edit it right now): You can write callbacks of static class … Continue reading

Posted in PHP Development, Pressed, The Know Your Language Department | Tagged , , , , , , , , , , , | 1 Comment

SimpleXML Type Cheatsheet

A SimpleXMLElement can represent many different things, from an element, to a list of attributes or childelements. Sometimes it’s good to know how to find out, especially with the magic the extension comes with. The following is a table with … Continue reading

Posted in Hakre's Tips, PHP Development, Pressed, The Know Your Language Department | Tagged , , , , , , , , , | 1 Comment

PHP Autoload Invalid Classname Injection

There are many ways to attack an application, many are working by injecting some malicious data hoping to trigger a deserved action in the end. Most of these are possible when input data is not properly sanitized. This can have … Continue reading

Posted in Features, Hakre's Tips, PHP Development, Pressed, The Know Your Language Department | Tagged , , , , , | 1 Comment

Debug with Xdebug on the Commandline with Phpstorm and Git Bash

Enable Phpstorm Xdebug listening: Press the listen button inside Phpstorm to actually listen: To disable Phpstorm Xdebug processing in Bash again: This (PHPSTORM) is the default Phpstorm IDE-Key. You don’t need to disable listening after the variable is unset. Should … Continue reading

Posted in Hakre's Tips, PHP Development, Pressed | Tagged , , , , | 1 Comment

Getting N Random Elements out of an Iterator – RandomIterator

Considering there is an Iterator or Traversable with an unknown number of elements, I wondered if it is possible to get one or more random iterations out of it.

Posted in Developing, Hakre's Tips, PHP Development, Pressed | Tagged , , , , , , | Leave a comment