So, you’re playing around with your new Laravel toy and living your developer dream? Good!
Isn’t that awesome? Learning a new program/framework/whatever is always exciting and extremely rewarding, so, just because I feel you and I totally understand you, here are my personal tips about 5 things that everyone should do after the first installation and before starting to develop something with Laravel.
Activate the Debug
By default the Debug option in Laravel is deactivated, that means if your application encounters an error for whatever reason, it’ll display a totally anonymous page like this one.
And of course you will be like “OMG, what’s going on???”, but before starting to freak out, you can easily activate a more complete error messaging system by simply accessing the file app.php located inside this path:
app/config/app.php
Here you change the value of the variable debug, from false to true. Now, if an error will occur Laravel will tell us everything about it.
Way more useful, but of course remember to put the variable back to false before releasing your application.
Configure your Timezone
In the same file you can also properly configure your Timezone variable to match your server or country time zone. This is important because this setting will affect the timing of the date and date-time functions, and of course your ability to easily check when something happened.
Configure your Database
To configure a database connection, local or remote, open the database.php file located in the same folder as the app.php file. Here you can set the parameters for you favourite database and put it as the default one. This file is really handy because it gives you the ability to configure multiple databases at the same time and easily select the one to use by changing the value of the default variable. Just remember that Laravel needs a database password, even if you’re creating a connection to a local one.
Switching from your development database to the production one has never been so easy.
Create a default View with .blade
Using Laravel and not using the .blade extension from the beginning is like going for an ice cream and ask to put it on your hand without the cone. Poor ice cream…
Blade is the default and super powerful template engine that comes with Laravel, and to use it you just have to add the extension .blade to all your files (e.g. index.blade.php)Â
In this way all your files will be “connected” to each other, giving you the ability to include files inside others or only portion of those files, printing PHP variables without using any PHP syntax and appending multiple contents dynamically such as sidebar or footer.
Pretty awesome, right? For more informations and a small tutorial take a look at the official documentation of the Laravel Template System
Take a step back and think about your structure
This is more a personal recommendation than an actual advice. Laravel is really powerful and easy to use, but at the beginning can be really confusing and sort of messy. So, before putting your head down and start coding, remember to take a deep breath and think about your goals, which controllers you’ll need and how to split all your views into a clean and accessible folders structure.
Always remember that things could get out of control really fast!
Well, that’s it, those are my tips and I really hope that someone will find them useful.
And what about you? What’s your “something that you should totally do” after the Laravel installation?
If you have more tips or suggestions please write a comment and I will add them to this list, and of course if you liked this article please think about sharing it.
Cheers