First project; Learning Laravel week 3

In what might be the final post on learning Laravel with this being the week 3 blog post.

The outcome being I released my first project made with Laravel which was actually just a rebuild of My idlers (Originally Vanilla PHP).

Learning Laravel PHP 3

The project can be found here. It is CRUD based with authorization (Laravel Breeze).

Now for the thoughts and findings during week 3:

No command for database creation

For Laravel there is no single, one-line command to create the database. Given Migrations handles the structure and creation for tables creating the actual database should too be a simple Artisan command.

Instead, you have to build up a small custom command to create the database or connect and run a query on the database using the command line or a GUI program.



Setting and getting sessions is done in a simple manner alike to Vanilla PHP:

Session::put('session_name', $value);


Getting all of the session data:


Checking if session contains a value:


Forgetting a value or flushing all of the session data:




Thanks to getting the base git .ignore file for a Laravel and PHPStorm project was easy. The direct link is here for the two combined.

This helped to ensure only the essential files were committed to GitHub and all the unnecessary files were not.

Blade @yield and @section

Yield and section in blade files allows for injecting into layouts on certain pages



Then in the layout child

    body: {
        color: #7b6f6f;

This will put the CSS styling in the header of the child page. Doing it this way is for when you want styling or scripts on only certain pages and not the whole inheritance of app layout.

Sitemap generator

Laravel sitemap is a package to generate a sitemap without having to manually enter URLs. Its usage can be just 2 lines:

use Spatie\Sitemap\SitemapGenerator;


Custom error pages


Custom error pages can be used by creating a blade file in resources/views/errors/ with the status code being the file name e.g 404.blade.php

Symfony\Component\HttpKernel\Exception\HttpException gets passed in as $exception.

<h2>{{ $exception->getMessage() }}</h2>