Travis CI – Laravel Forge / webhook integration

While developing tests for my app, I wanted to have an integration with Laravel Forge in this order:

  1. Push to Github after commit
  2. Tests done by Travis CI
  3. Call the deployment trigger url of Laravel Forge / Envoyer if the test runs successfully. This URL looks like:

To do this, create a travis.yml file like:

language: php

  - 7.1

  - cp .env.travis .env
  - mysql -e 'create database db_testing';
  - composer self-update
  - composer install --no-interaction
  - php artisan migrate

  - vendor/bin/phpunit

  - chmod +x ./; ./

Don’t forget to change the environment in phpunit.xml for example to change to a custom database:

The after_success script

Create a file and insert:


# Trigger deployment
# Replace the url below with your Forge/Laravel url
curl -s '';
echo 'Deployment triggered!'


Using other services than Travis or creating a custom test service

Also thanks to:

Laravel Speed and Performance Optimization 101 – The Guideline

speed-1249610_1920I am working with a pretty heavy Laravel site with many requests and lots of Eloquent/SQL calls. Even though the high-memory and high-cpu VPS, I felt there is room for performance improvement. That is why I would like to write out some improvements to speed up Laravel:

1. Use Database or Redis for cache and sessions

When you navigate to config/cache.php and config/session.php, you see that the default CACHE_DRIVER and SESSION_DRIVER = file. If you have Redis installed, just try to set it as a cache and session driver. Check if Redis is installed by running:


If it is installed, try to define the drivers in your .env file:


2. Use several artisan pre-made commands

There are various artisan commands that are made to cache several parts of Laravel. You can configure them in the deployment process of Laravel Forge or Envoyer:

php artisan route:cache
php artisan config:cache
php artisan optimize --force


Use Developer tools guideline

Do a run at and optimize several steps:

3. Optimize images like PNGs and JPEGs

Images sometime possess useless extra data that can be lossless optimized. Therefore you can use the packages OptiPNG and JPEGOptim. In Ubuntu install OptiPNG:

sudo apt-get update
sudo apt-get install optipng

And also install JPEGOptim:

sudo apt-get install jpegoptim

Now navigate to the folder that you would like to optimize its images. For optipng run:

optipng *

For jpegoptim run:

for i in *.jpg; do jpegoptim --all-progressive "$i"; done

Note that also the subdirectories might be optimized

4. Use HTTP2 instead of HTTP 1.1 if you have an SSL certificate enabled

The following guideline helps you through the process of updating to HTTP2 in Nginx.

Note that you need to have a SSL certificate. Google PageSpeed gave a server speed change from 0.52s (without HTTP2, with SSL) to 0.35s (with HTTP2)

Result: About 30% speed increase

5. Cache response in Redis or File

Sometimes it is unnecessary that the page is called from a database many times. Just caching the page reduces quite some load. That is exactly the same idea of the Laravel Response Cache plugin. The install instructions are quite good. In my case it had a drastic performance improvement.

Result: about 200 ms speed increase in my case

6. Optimize InnoDB innodb_buffer_pool_size

I am not sure why, but for some reason InnoDB has a really small innodb_buffer_pool_size when deploying your initial Laravel Forge server. In my default case, the innodb_buffer_pool_size was 8MB, while some blogs estimate that you can reserve up to 80% of your ram for innodb_buffer_pool_size. So edit the my.conf file:

sudo nano /etc/mysql/my.cnf

And add for example:

innodb_buffer_pool_size = 1G

Result: Several times faster queries

7. Reduce load by adding swap

My server regularly had Redis full-memory issues and high loads. This was solved by adding some swap to Ubuntu. As described by DigitalOcean:

One of the easiest way of increasing the responsiveness of your server and guarding against out of memory errors in your applications is to add some swap space. Swap is an area on a hard drive that has been designated as a place where the operating system can temporarily store data that it can no longer hold in RAM.

Read more about adding swap at the DigitalOcean website.

Result: a reduction in load when entering the ‘top’ command

This list is still a work-in-progress list, although above tips gave me a speed improvement of MORE THAN 1 SECOND. Got any tips, let me know in the comments!

Also share your speed improvements 🙂

Laravel 5.3 change login path and prevent registration

Prevent that /login is the default path for login

Thanks to Stackoverflow. Go to your routes/web.php

And change:



// Login
Route::group(['middleware' => ['web']], function() {
    Route::get('login-new-address', ['as' => 'login', 'uses' => 'Auth\LoginController@showLoginForm']);
    Route::post('login-new-address', ['as' => '', 'uses' => 'Auth\LoginController@login']);
    Route::post('logout-new-address', ['as' => 'logout', 'uses' => 'Auth\LoginController@logout']);
// Registration Routes...
    Route::get('register', ['as' => 'register', 'uses' => 'Auth\RegisterController@showRegistrationForm']);
    Route::post('register', ['as' => '', 'uses' => 'Auth\RegisterController@register']);

// Password Reset Routes...
    Route::get('password/reset', ['as' => 'password.reset', 'uses' => 'Auth\ForgotPasswordController@showLinkRequestForm']);
    Route::post('password/email', ['as' => '', 'uses' => 'Auth\ForgotPasswordController@sendResetLinkEmail']);
    Route::get('password/reset/{token}', ['as' => 'password.reset.token', 'uses' => 'Auth\ResetPasswordController@showResetForm']);
    Route::post('password/reset', ['as' => '', 'uses' => 'Auth\ResetPasswordController@reset']);

Would you like to prevent registration?

Remove the registration and password reset routes if you don’t want people to register, e.g. for admin panels.

Also change your redirect if not logged in

Change in App/Exceptions/Handler.php the redirect to:

return redirect()->guest('login-new-address');