Co-operative Multitasking in PHP
A very nice post by Christopher Pitt about generators and how to use them to run code asynchronous.
https://medium.com/%2540assertchris/co-operative-php-multitasking-ce4ef52858a0
A very nice post by Christopher Pitt about generators and how to use them to run code asynchronous.
https://medium.com/%2540assertchris/co-operative-php-multitasking-ce4ef52858a0
In PHP, variable allocation is really easy, you don’t really need to know how memory is managed to use the language. But if you want to be a good programmer, you NEED to know what happens when you write “$var = 10;”http://blog.thedebian.com/post/79117048456/what-happens-when-i-allocate-a-php-variable
Join 9,500+ smart developers
Get my monthly newsletter with what I learn from running Spatie, building Oh Dear, and maintaining 300+ open source packages. Practical takes on Laravel, PHP, and AI that you can actually use.
No spam. Unsubscribe anytime. You can also follow me on X.
"Freek publishes a super resourceful and practical newsletter. A must for anyone in the Laravel space"
Here's another cool piece of code by Matthias Verraes:
Yep, that's the entire test framework. More info at:function it($m,$p){echo ($p?'✔︎':'✘')." It $m\n"; if(!$p){$GLOBALS['f']=1;}}function done(){if(@$GLOBALS['f'])die(1);}
Having documentation on your API is highly beneficial. If it is well written you're likely going to receive less questions by consumers of your API about how it works.
Aglio is a nice tool that I've been using to generate API documentation. In goes the Markdown, out comes the beautiful documentation.
As you may know, the Scalar Type Wars are over. It has been decided that we will have scalar type hints in PHP7.
Here's a nice short write up on the three related accepted RFC's by Er Galvao Abbott.
Socialite is a first party package that was introduced together with Laravel 5. It aims to provide a very convenient way to authenticate with OAuth providers. Natively it supports Facebook, Twitter, Google, GitHub and Bitbucket.
DraperStudio and Andy Wendt made a whole bunch of other Socialite providers.
The `yield` keyword is used by generators, which provide a simple way to implement iterators without having to create a class that implements the `Iterator` interface. A generator allows you to write code that iterates over a set of data without needing to build an array in memory that is returned at the end.http://jenssegers.be/blog/66/behold-the-power-of-yield
On the internals mailing list Anthony Ferrara posted a plea for unity on scalar types. If you want to know why it's so difficult to add scalar type hints to PHP, you should read it.
Scalar types are a hard problem. Not technically, but politically, because so many people use PHP in different ways. And everyone thinks their way is "the one true way".http://news.php.net/php.internals/84689
The RFC needs a 2/3 majority to pass. The yes-camp currently has 67%. Personally I really hope this proposal will get accepted.
Excellent post by Rafael Dohms on the The League Of Extraordinary packages.
“The League of Extraordinary Packages” is what I have dubbed a collective of composer packages. Its essentially a group of developers who have gathered under a single flag (or in this case a vendor name) and set standards for the packages that live there.http://blog.doh.ms/2015/03/10/why-i-support-the-league/...
So these are a few reasons I like this effort:
- Imposed Quality, Curated List ...
- Reduced author fragility ...
- Extended reach ...
- Reduced duplication ...
Matthew Setter went to the rabbi.
I don’t have a specific conference in mind, but I’ve given myself the next 12 months. I think that’s a practical and realistic amount of time, yet still short enough to not lose sight of.http://www.matthewsetter.com/path-first-php-conference-talk/
A list of interesting conference talks and videos on PHP.
https://medium.com/@genealabs/run-allthecommands-outside-of-homestead-e2fc8d05251fThe accepted solution thus far has been to install newer versions of PHP alongside Apple’s version using Homebrew or MacPorts. This would likely require you to compile the MCrypt extension manually. I also found that Homebrew could leave your system in disarray if things went wrong (more than once I had to do a complete restore because of this).
However, there’s another method I came across while research some non-related issues: install the latest version of PHP from a binary that includes the MCrypt extension. It will not bork up your system if you want to remove it, either.
The next major release of PHP, version 7, is going to be an awesome release. Not only will performance be greatly improved, there probably will be lots of nice changes to the language.
The procedure on how PHP gets changed is easily readable and well documented. In short it comes down to this:
Last week I made a Laravel 5 package that could dump your db. Last saturday night I took the time to expand the functionality. laravel-backup can now backup your entire application. The backup is a zipfile that contains all files in the directories you specify along with a dump of your database. The…
Michael Maclean demonstrates how a 2100% performance gain can be achieved when rendering a Mandelbrot fractal using Recki-CT, a PHP compiler written in PHP.
Recently, Anthony Ferrara (known throughout the Internet and beyond as @ircmaxell) and Joe Watkins (similarly well-known as @krakjoe) have been working on a new set of toys for solving this problem while staying on the “standard” PHP runtime. Recki-CT is a set of tools that implement a PHP compiler, in PHP. While this might you think of things like PyPy, which implements a Python virtual machine in Python, this is not Recki’s goal – it doesn’t provide a VM, so it can’t run PHP by itself. However, it can parse PHP code and generate other code from it.http://mgdm.net/weblog/php-at-the-speed-of-c/
Middleware is a series of wrappers around your application that decorate the request and the response. By wrapping the app in decorators you can add new behavious from the outside. This image explains the idea more visually:
[caption id="attachment_475" align="alignnone" width="726"]
source: StackPHP.com[/caption]
The concept isn't new, solutions already exists for many languages (eg. Ruby, Python, Node, ...)
The PHP equivalent is StackPHP. Here's an excellent post by Richard Bagshaw explaining it. There are a lot of StackPHP style middlewares available that you can use in your applications.
Laravel 5 uses middleware for putting an application in maintenance mode, CSRF protection, authentication and more. Unfortunately Laravel 5 middleware isn't compatible with StackPHP-style middleware. Barry vd. Heuvel created at package to convert StackPHP middleware to Laravel 5 middleware and explained the inner workings on his blog.
Matt Stauffer shows how he built Gistlog in under two hours.
Gistlog is a blogging "platform" for people who want to quickly write and publish content, in Markdown, and don't want to bother with yet another platform and yet another login and yet another group hoarding their content. With Gistlog, you use your pre-existing Github login, you store the data in your own Github account, and you can publish with a single click.A must see if you want to know how to get things done quickly in Laravel.
https://www.youtube.com/watch?v=g4BbeHYCR1E
Also make sure you check out his blogposts on the new features of Laravel 5.
Recently some of the Laravel-packages I built at Spatie were updated for Laravel 5.
spatie/laravel-glide This package enables you to generate image manipulations on the fly and generate URL's to those images. These URL's will be signed so only you will be able to specify which manipulations should be generated. Every manipulation will be cached. Under the hood, Glide is being used.
spatie/searchindex This is an opinionated package to store and retrieve objects from Elasticsearch. It was tailormade for a project I was working on and only provides the functionality that I needed. If you need full control over elasticsearch via PHP, take a look at the official low-level client.
spatie/googlesearch This package can fetch results from a Google Custom Search Engine. It returns an array with searchresults.
eloquent-sortable This package provides a trait that adds sortable behaviour to an Eloquent model. The value of the ordercolumn of a new record of a model is determined by the maximum value of the ordercolumn of all records of that model + 1.
A big thank you goes out to Matthias De Winter, who is helping me update these packages.
For my own reasons, I have decided to cease my involvement with PHP development. This isn’t a judgement of the PHP community nor the internals mailing list, you’re all wonderful people and it’s really been a pleasure, and I mean that completely honestly. However, this has ended up taking up too much of my time (which is my own fault, and my own fault alone) and I can’t really justify it to myself anymore.http://news.php.net/php.internals/82750So, I’m no longer contributing to PHP, and all four active RFCs authored by myself are therefore withdrawn: Scalar Type Hints, Spaceship/Combined Comparison Operator, Void Return Type, Big Integer Support.
Damn.
This chart shows the number of requests per second that were performed (more is better). You can see that PHP 7 can do a lot more in comparison with the other versions. Response times drop from 0.2269 to 0.0865 seconds in the production environment.http://www.intracto.com/nl/blog/running-symfony2-on-php7
Nice benchmark-work by Tom Van Looy. It is clear that you'll benefit from impressive speed bumps when upgrading to the next major version of PHP. Tom also provides instructions on how to setup PHP7 so you can perform your own tests.