Laravel allows us to validate requests before they even make it to our controllers. It does this using named form requests
Thus you might write a controller action like so:
public function storeBlog(BlogRequest $request)
This is a country song about a love burnt out over time like a candle. This story starts with a young boy. This boy fell in love with a beautiful programming language. The boy grew into a man, becoming more and more cynical over time. Eventually he lost his way and his first love.
So in this article I’m going to explain how to test every route in a laravel application. I usually name all the routes in my application, so essentially, every route in my application has some sort of sanity test.
One thing that annoys me about homestead is that I have to switch to the Homestead directory in order to use vagrant.
Instead I made a little helper that takes out a step. Now I can just run
Ever wanted to see errors happening on your application? I use rollbar for this. And unless your app has over 5000 errors a month, it is free.
Installing Rollbar for Laravel is super easy. Below is the code you get when you first sign up for Rollbar.
My work buddy and I were talking about tests. We wanted something to go through every route in our system and check for any obvious errors. That seemed like a pretty simple way to test an application.
So I wrote a generator to create tests for me automatically at work. I wanted to test every route we have in the system. We have hundreds of routes on this particular project I’m working on today. On our last large project we had over a thousand routes. What can I say? We like our routes.
A while back I wrote about downloading a file in Laravel and then removing the file. This prevents us from having to clean up the storage directory full of files with a cronjob. I recently had this issue come back up at work and now we are on Laravel 5. Let’s revisit this issue.
Laravel 5 gives us a nifty little command to change our application’s namespace. Out of the box the default namespace is
App. To change it, we simply run:
php artisan app:name Horsefly
However, once you register your app namespace, how do you get it later? Laravel doesn’t save it in config(‘app.name’) or anything like that.
When you want to monitor a github repo, you can setup travis-ci, hudson or bamboo continous integration (CI) server. A problem arrises though. What if you want to run scripts on a server that is behind a firewall? The CI server may not be able to access this private server behind your protected network.
This is where gitmon is used. We can monitor the git repository for changes and then when things do change we can run a changed script. The changed script is placed within the repository itself so developers can work with it. This changed script can email people, run bash commands, whatever you want it to do.