I’m working on a PHP project, that uses Phil Harveys excellent ExifTool to read Exif and XMP tags from photos. Since ExifTool is written in Perl, there is of course no composer.json to install this dependency directly with Composer. But you can create your own package information in your master composer.json as follows: { … …
How to update Composer on Linux Mint 18.3
When you install Composer (the dependency manager for PHP) globally on Linux Mint 18.3 with the package manager… $ sudo apt install composer $ composer -V Composer version @package_branch_alias_version@ (1.0.0-beta2) 2016-03-27 16:00:34 …you’ll get the totally outdated version 1.0.0-beta2. The problem is that this version does not support extracting compressed package files ‘tar.gz’. It also …
Continue reading “How to update Composer on Linux Mint 18.3”
Apache serves cached files with garbled text at end
When using Apache running on a VirtualBox machine with a shared folder, small files such as JavaScript or CSS files might not get updated from the host and served with additional characters at the end. This happens because of a bug in VirtualBox when Apache is using sendfile to improve data transfer. Just turn the …
Continue reading “Apache serves cached files with garbled text at end”
Why is your PHP output still buffered even when you turned buffering off?
If you want to stream your content with PHP, you need to have output_buffering set to off in you php.ini and/or use it together with flush(). If this still does not work check your Antivirus software. On Windows, the on-access scanners of Sophos and Avira Antivirus buffer your http output! The only solution is to …
Continue reading “Why is your PHP output still buffered even when you turned buffering off?”
PHP: How to sort a NodeList by element attribute
$elements = iterator_to_array($nodeList); usort($elements, function($a, $b) { return (int) $b->getAttribute(‘someAttribute’) – (int) $a->getAttribute(‘someAttribute’); });
Streaming large data (LOBs) directly into an Oracle database with PHP
The OCI library allows you to stream large data in chunks directly into a LOB instead of loading it completely into memory first. This technique is only mentioned in the article Working with LOBs in Oracle and PHP on the Oracle Technology Network, but no code example is given there, so here’s my take: $sql …
Continue reading “Streaming large data (LOBs) directly into an Oracle database with PHP”
PhpStorm: Complete code versus complete current statement
Here are two useful keyboard shortcuts for PhpStorm which sound similar, but are quite different: complete code CTRL + SPACE will either finish your code if what you typed so far is unambiguous or otherwise offer a list to choose from. complete current statement CTRL + SHIFT + ENTER will add a semicolon at the …
Continue reading “PhpStorm: Complete code versus complete current statement”
Linux Mint 17: Install php_oci
Quick cooking recipe to install PHP oci8 on Linux Mint 17 / 18. Download the Instant Client from the Oracle Website and follow the instructions at the bottom of the download page. Download the Instant Client SDK from the same location, unpack it and move the SDK folder to the same folder where the Instant …
PHP Tip: Binding variables in a SQL WHERE IN clause
Have you ever wondered if it is possible to bind an unknown amount of variables in a SQL WHERE IN clause, e.g.: SELECT id, text FROM myTable WHERE id IN (:myId1, :myId2, myId3, …) Use a OCI collection object and wonder no more: $keyList = array(100, 250, 350); $stmt = oci_parse($cnn, “SELECT id, text FROM …
Continue reading “PHP Tip: Binding variables in a SQL WHERE IN clause”
SQL tip: How to bind NULL with PHP and Oracle
Neat little trick to bind a null value without using an if clause. How often have you done something like this when a variable might be null: $sql = “SELECT * FROM someTable WHERE col1 = :firstVar”; if ($secondVar !== null) { $sql.= ” AND col2 = :secondVar”; } … oci_bind_by_name($stmt, ‘:firstVar’, $firstVar); if ($secondVar …
Continue reading “SQL tip: How to bind NULL with PHP and Oracle”