Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Laravel News:
Using Named Routes in a Lumen Test
Nov 21, 2017 @ 12:56:49

On the Laravel News site there's a quick tutorial posted showing you how to use named routes in Lumen in writing tests for your application.

When writing tests in Lumen, I recently discovered that the route() helper doesn’t work with tests out-of-the-box.

I prefer to define named routes and make requests against them in my tests. If you follow the Lumen documentation, the typical way that you make a request for a test [of the return of a JSON endpoint results in an error message]. [...] If you inspect things a little closer, you can see the issue: [...] Interestingly, the route doesn’t look quite right, and the router is returning the / route. It looks like the localhost part of the request isn’t being set, and the route isn’t matching. We can fix that by bootstrapping the request as Laravel does.

The post then walks you through the manual process of bootstrapping things so that routes are correctly resolved. This includes changes to the code for the base test case to handle the "boot" and set the path value for the request correctly.

tagged: named lumen route test request boot base testing tutorial

Link: https://laravel-news.com/using-named-routes-lumen-test

Tiger Heron Blog:
First steps with PHP - booting a script, Part 2
Apr 28, 2008 @ 12:57:33

Tony Freixas continues his introductory look at "booting" a PHP script with part two of his series (here's part one) looking at using libraries.

In the good old days, if you wanted to create re-usable code, you would create a library of related functions or objects. Now, the excitement is all around frameworks. Everyone has one. What is the difference between the two?

He compares a library and a framework, pointing out key differences like how they fit with the application (controlled by or controlling) and dependencies they require. He rounds out his boot sequence, adding a few new parts to the structure of his example application.

tagged: series boot script introduction library framework

Link: