// Contents of Envoy.blade.php @servers(['web' => 'deploy-ex']) <?php $repo = '[email protected]:Servers-for-Hackers/deploy-ex.git'; $release_dir = '/var/www/releases'; $app_dir = '/var/www/app'; $release = 'release_' . date('YmdHis'); ?> @macro('deploy', ['on' => 'web']) fetch_repo run_composer update_permissions update_symlinks @endmacro @task('fetch_repo') [ -d {{ $release_dir }} ] || mkdir {{ $release_dir }}; cd {{ $release_dir }}; git clone {{ $repo }} {{ $release …
Tag Archives: php
PHP Scalar Type Hints
At this moment a vote on the PHP RFC “Scalar Type Hints” is going on. It would allow stuff like this: <?php class ElePHPant { public $name, $age, $cuteness, $evil; public function __construct(string $name, int $age, float $cuteness, bool $evil) { $this->name = $name; $this->age = $age; $this->cuteness = $cuteness; $this->evil = $evil; } } …
Transducers in PHP
use Transducers as t; $xf = t\comp( t\drop(2), t\map(function ($x) { return $x + 1; }), t\filter(function ($x) { return $x % 2; }), t\take(3) ); $data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; $result = t\xform($data, $xf); // Contains: [5, 7, 9] Transducers are composable algorithmic transformations. They are independent …
PropelORM
<database name="default"> <table name="book"> <column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true"/> <column name="title" type="varchar" size="255" required="true" /> <column name="isbn" type="varchar" size="24" required="true" phpName="ISBN"/> <column name="author_id" type="integer" required="true"/> <foreign-key foreignTable="author"> <reference local="author_id" foreign="id"/> </foreign-key> </table> <table name="author"> <column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true"/> <column name="first_name" type="varchar" size="128" required="true"/> <column name="last_name" type="varchar" size="128" required="true"/> </table> </database> $book = …
hashids
$hashids = new Hashids\Hashids(‘this is my salt’); $id = $hashids->encode(1, 2, 3); $numbers = $hashids->decode($id); Hashids is a small open-source library that generates short, unique, non-sequential ids from numbers. You give it a 347 and it gives back “yr8”, you give it a [27, 986] and it returns “3kTMd”. You can also decode those ids …
ANSI Control Functions and ANSI Control Sequences (Colors, Erasing, etc.) for PHP CLI Apps
As a side project for Monolog Colored Line Formatter (which int itself also is a side project for Mixed Content Scan) I just published is ANSI PHP. bramus/ansi-php is a set of classes to working with ANSI Control Functions and ANSI Control Sequences (ANSI Escape Sequences) on text based terminals. ANSI Control Functions control an …
Monolog Colored Line Formatter
Over a year ago I quickly whipped up a Colored Line Formatter for use with Monolog. As I’m building colorised output into Mixed Content Scan I – finally – took the time to actually put the darn thing out in the open. bramus/monolog-colored-line-formatter is a formatter for use with Monolog. It augments the Monolog LineFormatter …
PHPCI – Continuous Integration for PHP Projects
PHPCI is a free and open source continuous integration tool specifically designed for PHP. Built with simplicity in mind and featuring integrations with all of your favourite testing tools, we’ve created the very best platform for testing your PHP projects. Looks interesting. Host it yourself, or make use of one of the hosted plans. PHPCI …
Continue reading “PHPCI – Continuous Integration for PHP Projects”
PHP 7: Immediately Invoked Function Expressions
PHP7 will continue to borrow some of the beloved JavaScript features and will support Immediately Invoked Function Expressions (IIFEs): <?php echo (function() { return 42; })(); Output for php7@20140901 – 20141101: 42 Since we can already return functions from inside other functions, Currying Partial Application is also possible in combination with the IIFE implementation: <?php …
Continue reading “PHP 7: Immediately Invoked Function Expressions”
AWS Resource APIs for PHP
<?php require 'vendor/autoload.php'; use Aws\Resource\Aws; $aws = new Aws([ 'region' => 'us-west-2', 'version' => 'latest', 'profile' => 'your-credential-profile', ]); $bucket = $aws->s3->bucket('your-bucket'); $object = $bucket->putObject([ 'Key' => 'images/image001.jpg', 'Body' => fopen('/path/to/image.jpg', 'r'), ]); The core AWS SDK for PHP is composed of service client objects that have methods corresponding 1-to-1 with operations in the service’s …