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.

Common string functions

Link –

When working on projects I found myself, over time, needing the same string functions over and over again. Things like how to shorten a string but still let it end on entire word, replace the last occurrence of string in a string, ...

Instead of keeping these functions in a helper file locally in the project, I made a package out of it. It was a good opportunity to spice it up with bit of OO to make them chainable. An example:

[code] // outputs "MIDDLE" echo string('StartMiddleEnd')->between('Start', 'End')->toUpper();



In addition to it's own methods, the package provides <a href="https://github.com/spatie/string#integration-with-underscorephp">an integration</a> with <a href="https://github.com/Anahkiasen/underscore-php">Maxime Fabre's underscore package</a>.

You are very welcome to submit pull requests to add functions that you feel are missing. Be sure to include some unit tests to ensure everything working as intended.

Granted,  it isn't the most sexy package in the world, but it sure is handy.

<a href="https://github.com/spatie/string">https://github.com/spatie/string</a>

Read more

A Laravel package to easily add paginated routes

Original – by Freek Van der Herten – 1 minute read

Laravel offers a nice way to add pagination. As far as your routes are concerned you don't have to do a thing. It just works out of the box. Unfortunately the generated url's are pretty ugly: http://example.com/news?page=2 What we want are url's that look like this: http://example.com/news/page/2…

Read more

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.

Semantic versioning and public interfaces

Link –

...

Interfaces are more susceptible to BC breaks than concrete classes. Once an interface is published as “stable”, I don’t see how it can be changed at all per the rules of SemVer (that is, unless you bump the major version). The only thing you can do to maintain BC is add an entirely new interface to the package while leaving the old one in place, perhaps even extending the old one if needed.

http://paul-m-jones.com/archives/6136

Read more

What about "final" and "private"?

Link –

There was much discussion on Twitter about the concepts of using “final” and “private” in objects, and what exactly the best practices are. The conversation seemed to boil down to three distinct questions:
  • Should an object be open for extension, and expose its internals for that purpose?
  • Does exposure of those internals create a de facto contract with children for their behavior?
  • Should software only be used as intended by its designers, or should it be modified, extended and changed by the end user to fit certain, specific goals?
http://www.brandonsavage.net/what-about-final-and-private/

Read more

PHPUnit 5.0 will only support PHP5.6 and above

Link –

Active support for PHP 5.4 ended on September 14, 2014 and active support for PHP 5.5 will end on June 20, 2015. The active support for PHP 5.3 already ended on July 11, 2013. By the time PHPUnit 4.8 will be released, the only actively supported version of PHP will be PHP 5.6.

The next version after PHPUnit 4.8 will not support PHP 5.3, PHP 5.4, and PHP 5.5 anymore. As PHPUnit follows Semantic Versioning the major version number must be incremented when the minimum required version of PHP is increased.

https://github.com/sebastianbergmann/phpunit/wiki/Release-Announcement-for-PHPUnit-4.7.0#phpunit-50

Nice!

Read more

Handling private composer packages with Satis

Link –

Satis allows you to require private php packages in your projects. One of it's authors is Jordi Boggiano of composer/packagist fame. Over at the excellent Laravelista blog Mario Bašić explains how to install and use it.

I was working on three projects at the same time and I've found myself copying code from one project to another and then making small changes. And then I recognized a pattern. ...

I created a package and as soon as it was ready for GitHub I remembered: "I can't open source this...". The package contained few paid html templates, company logo's, slogans, specific company text etc. ...

This post will explain what Satis is, when to use it and how to set it up on your server.

Read more

Get data from Google Analytics on legacy sites

Link –

Nearly all greenfield projects at Spatie are built with Laravel. A few months ago I made laravel-analytics, a package to fetch data from Google Analytics.

Spatie exists for more than ten years so there are quite a few legacy projects as well. In those projects there is also a need to display some analytics data in the admin-section. Recently Google retired some of their older API's. Unfortunately our old solution to fetch GA data stopped working.

To resolve this problem my colleague Sebastian created a framework agnostic version of laravel-analytics that works with PHP 5.3. If you also have a legacy project that needs some data from Analytics, you can install the package via composer.

Read more

Learn by listening to these podcasts

Link –

The past few months, I've been trying out some podcasts. Listening to them is an easy way to learn about and stay in touch with the sprawling range of topics that could interest a developer. These are my favourites:

The Laravel Podcast

The Laravel podcast focusses on Laravel (of course) and the latests trends in the PHP world. The podcast is hosted by Matt Stauffer. Jeffrey Way and Taylor Otwell are regular guests. Recently the format of the show was changed: episodes are now around 30 minutes in length, which I think is great.

Listen in iTunes Follow on Twitter

Full Stack Radio

This podcast isn't narrowly focused on one subject. In each episode Adam Watham interviews one guest. Topics range from product design to system administration and everything in between. To give you an idea: the last episodes saw Adam Culp talking about conferences, Kent Beck about application architecture and Konstantin Kudryashov about BDD and TDD.

Listen on iTunes Follow on Twitter

Dev Discussions

In this podcast Shawn McCool talks with other webapplication dev's mainly about programming concepts. Past episodes touched functional programming, event sourcing, ActiveRecord and Datamapper. Shawn recently recorded a talk with Mathias Verraes and Ross Tuck. Let's hope it gets published soon.

Listen on iTunes Follow on Twitter

PHP Roundtable

The roundtable was created by Sammy Kaye Powers. On each episode several developers discuss various topics concerning PHP and it's ecosystem.

Listen on iTunes Follow on Twitter

I'm sure there are many other great podcasts out there. If you know one, please let me (and the other readers of this blog) know in the comments below.

Read more

We have a problem with promises

Link –

Q: What is the difference between these four promises?
doSomething().then(function () {
  return doSomethingElse();
});

doSomething().then(function () { doSomethingElse(); });

doSomething().then(doSomethingElse());

doSomething().then(doSomethingElse);


</div>
If you know the answer, then congratulations: you're a promises ninja. You have my permission to stop reading this blog post.</blockquote>
<a href="http://pouchdb.com/2015/05/18/we-have-a-problem-with-promises.html">http://pouchdb.com/2015/05/18/we-have-a-problem-with-promises.html</a>

Read more

Rendering ReactJS templates server-side

Link –

Some unknown guy (ok, he is famous for writing the fantastic Flysystem) has written an insightful post on his new blog on how and why to render ReactJS templates on the server.

Rendering your templates server-side has some obvious benefits. Since the contents of the page is there in the initial response, there's less page build-up. This will give your application a more snappy feel to it. It also ensures your pages can be correctly indexed by search engines. An additional bonus is presented in the way that React handles your pre-rendered page.

When React templates are rendered server side, a checksum is added. This hash is checked by the front-end ensuring the UI is in the correct state, and if so, that representation of the DOM is accepted, preventing any further rendering on the client. This, once again, creates a smoother experience in terms of performance.

I'm looking forward to Frank's future posts.

Read more

Tilde and caret version constraints in Composer

Link –

There are also some syntactic sugar operators like `~` (tilde) and `^` (caret).
  • `~4.1.3` means `>=4.1.3,<4.2.0`,
  • `~4.1` means `>=4.1.0,<5.0.0` (most used),
  • `~0.4` means `>=0.4.0,<1.0.0`,
  • `~4` means `>=4.0.0,<5.0.0`.
The caret sign is slightly different:
  • `^4.1.3` (most used) means `>=4.1.3,<5.0.0`,
  • `^4.1` means `>=4.1.0,<5.0.0`, same as `~4.1` but:
  • `^0.4` means `>=0.4.0,<0.5.0`, this is different from `~0.4` and is more useful for defining backwards compatible version ranges.
  • `^4` means `>=4.0.0,<5.0.0` which is the same as `~4` and `4.*`.
 
http://blog.madewithlove.be/post/tilde-and-caret-constraints/

Read more

Creating packages

Original – by Freek Van der Herten – 2 minute read

Prosper Otemuyiwa recently wrote an article on how to create Laravel 5 packages on his blog. Although his approach is entirely valid and may suit you well, I work a little differently when creating a new package. First, I create a new GitHub repository where the package will live. In that repo I…

Read more

Fetch: the new AJAX API

Link –

One of the worst kept secrets about AJAX on the web is that the underlying API for it, `XMLHttpRequest`, wasn't really made for what we've been using it for. We've done well to create elegant APIs around XHR but we know we can do better. Our effort to do better is the `fetch` API. Let's have a basic look at the new `window.fetch` method, available now in Firefox and Chrome Canary.
http://davidwalsh.name/fetch

Read more