Sevalla is the all-in-one PaaS for your web projects. Host and deploy your applications, databases, object storage, and static sites. Enjoy advanced deployment pipelines, a complete database studio, instant preview apps, and one-click templates. The pricing is simple: no hidden fees, no seat-based pricing, and you pay only for what you use. Get real human support from developers.
Get started now with a $50 credit at Sevalla.com.
Recommended reading: Clean Code
The last few weeks I made the time to read Clean Code by Robert C. "Uncle Bob" Martin. It's loaded with small and big tips and advice on how to improve the readability of your code and why this is important. Recommended reading for programmers of all levels.
A quote:
I am not expecting you to be able to write clean and elegant programs in one pass. If we have learned anything over the last couple of decades, it is that programming is a craft more than it is a science. To write clean code, you must first write dirty code and then clean it.This should not be a surprise to you. We learned this truth in grade school when our teachers tried (usually in vain) to get us to write rough drafts of our compositions. The process, they told us, was that we should write a rough draft, then a second draft, then several subsequent drafts until we had our final version. Writing clean compositions, they tried to tell us, is a matter of successive refinement.Most freshman programmers (like most grade-schoolers) don’t follow this advice particularly well. They believe that the primary goal is to get the program working. Once it’s “working,” they move on to the next task, leaving the “working” program in whatever state they finally got it to “work.” Most seasoned programmers know that this is professional suicide.
Stay up to date with all things Laravel, PHP, and JavaScript.
You can follow me on these platforms:
On all these platforms, regularly share programming tips, and what I myself have learned in ongoing projects.
Every month I send out a newsletter containing lots of interesting stuff for the modern PHP developer.
Expect quick tips & tricks, interesting tutorials, opinions and packages. Because I work with Laravel every day there is an emphasis on that framework.
Rest assured that I will only use your email address to send you the newsletter and will not use it for any other purposes.
Open a project in PhpStorm using the command line
This command will open your working directory in PhpStorm:
open -a /Applications/PhpStorm.app "
pwd"
For easy usage you can alias the command to "phpstorm".
Update: as mentioned by Nicolas Widart on Twitter and rok in the comments below, you can also use PhpStorm's built in launcher.
PHP UK Conference 2015 videos
The PHP UK Conference had a great schedule this year. Most sessions were recorded and are now available on YouTube. Happy viewing!
ES6 snippets
This site provides an overview of the shiny new ES6 features and a comparison to more traditional JavaScript. I certainly like the new syntax for creating and using classes.
Update: not everyone shares my enthusiasm for the new syntax regarding classes.
Clean up your Blade views with @each
Eric Barnes of Laravel News news demonstrates a nice way to loop over a collection in a Blade view using @each
.
How many HTTP status codes should your API use?
... it’s important to remember that API design isn’t strictly about the practical implications on client and server software. The audience for an API is the developer who is going to consume it. Per the "principle of least astonishment," developers will have an easier time learning and understanding an API if it follows the same conventions as other APIs they’re familiar with.https://blogs.dropbox.com/developers/2015/04/how-many-http-status-codes-should-your-api-use/
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 million lines of code
Is a million lines of code a lot? How many lines are there in Windows? Facebook? iPhone apps?http://www.informationisbeautiful.net/visualizations/million-lines-of-code/
What happens when a PHP variable gets allocated
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
Test framework in a tweet
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);}
Generate documentation for your API
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.
The accepted scalar type hints RFC's
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.
Creating the open world kite real-time demo in Unreal Engine 4
This tech demo of Unreal Engine 4 looks amazing. Keep in mind that it isn't pre-rendered but running in real time.
https://www.youtube.com/watch?v=w6EMc6eu3c8
Everything in the open world Kite demo is running in real time in Unreal Engine 4 at 30fps. In addition to Unreal Engine 4 open world features, Kite features fully dynamic direct and indirect illumination, cinematic quality depth of field and motion blur, PBR photo modeled assets and procedural asset placement.Here is the making of:
https://www.youtube.com/watch?v=clakekAHQx0
A collection of providers for Laravel socialite
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 power of yield
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
Why it's so difficult to add scalar type hints to PHP
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.
A Laravel package to retrieve Google Analytics data
If you need to retrieve some data from your Google Analytics account in Laravel 5, then laravel-analytics is the package for you. Assuming the analytics tracking code is installed on your site, the package allows you to determine which pages are visited the most, which browsers are used most to…
Motion sensing using the doppler effect
Recently I stumbled upon an interesting paper for implementing motion sensing requiring no special hardware, only a speaker and mic! Unfortunately the paper didn't include code to test it, so I decided to reproduce it here on the web!https://danielrapp.github.io/doppler/
Cool!
Clone your package inside the vendor directory
Dimitrios Savvopoulos, the creator of the laravel-translatable package (which I use in almost every project), shared a very nice tip on how to develop a package while it is installed as a requirement.
If you have write access to a composer package repository, you have the possibility to continue its development while it is installed as requirement in another project. Let's see how we can accomplish this.http://dimsav.com/blog/9/git-repository-inside-composer-vendors
If you have another, possibly better, way to go about this, let me know in the comments.