Laravel is an open source PHP framework that is built with the view controller model and is equipped with various syntaxes. Since it was launched in 2011, making a website with Laravel much favored by various community programmers on Github, before then spread throughout the world.
This framework provides several types of PHP libraries and several other functions that can make it easier for you to write a line of code. The Laravel Framework was created with the aim of beautifying the way to create a website.
Laravel is famous for being simple and elegant because its manufacture is intended for end-users. This framework is also famous for its complete and always updated documentation. Every time there is an update to the latest version there is always an update to the documentation.
" The PHP Framework For Web Artisans "
On the main website page, Laravel describes herself as " The PHP Framework For Web Artisans ". The meaning is that Laravel is made for people who like art.
Our goal in this Laravel tutorial article for beginners is to make a Laravel study guide from scratch. Start from the preparation process before developing.
Laravel is very suitable for the development of quite complex systems. If only a simple system is not considered comparable to the development process.
What You Need to Prepare Before Following the Laravel Tutorial?
Before learning basic Laravel, there are a few things you need to know to make it easier to understand this Laravel tutorial. The following list is the basis that you can learn first before reading further this Laravel tutorial.
Server RequirementThe installation process is carried out on a web server. You can use a service provider or you can also use a laptop that has a web server installed.
Besides VPS, you can also use a hosting server to run websites built using the Laravel framework. But make sure the hosting server supports the use of Laravel.
Before carrying out the installation process, you need to make sure that the server you are using meets the following requirements.
How to Install Laravel & ConfigurationThere are various ways to install Laravel on Mac, Linux, and Windows. In this tutorial laravel we provide step by step how to use Laravel on the Linux operating system and install Laravel through the composer .
Step 1 - Download Composer
Note: Make sure LAMP Server is running properly.
To start the composer installation process , you can run the following command on the terminal.
$ curl -sS https://getcomposer.org/installer | php
$ sudo mv composer.phar / usr / local / bin / composer
If the order can't, you can visit the Download Composer website .
Once installed, you need to restart the Httpd Server.
$ sudo systemctl restarts httpd
If necessary, update the composer .
$ sudo self-update composer
Step 2 - Installing LaravelComposer is already installed, the next step is to install Laravel using the command:
$ global composer require "laravel / installer"When running this command the directory will change to /home/user/.config/composer automatically. This is to ensure the Laravel program can run on the system.
Check to make sure that Laravel has been successfully installed using the "laravel" command.
$ laravel new blogThe new laravel command will create a new Laravel installation with the folder name "blog" in the active directory.
If there is an error " Laravel PHP Command Not Found ", you can check the .bash_profile and add a command line to direct the "laravel" command line.
$ sudo nano ~ / .bash_profileand add rows
export PATH = ~ / .composer / vendor / bin: $ PATHIf the " laravel new blog " command has been run successfully, the "blog" folder will be created automatically in the active directory where the command is run. Enter the "blog" folder using the cd command , then use the " php artisan serve " command to run the development program on the local server.
$ php artisan serveThe command is to run a kind of virtual web server on Laravel. After running, access the URL http: // localhost: 8000, and you will see the following display:
The display is the result of calling the index index file that is in the folder / blog / public in the laravel installation that was run.
Laravel Folder StructureWhen making an installation in the previous Laravel tutorial section, the Laravel folder structure is formed, the following is how it looks, complete with an explanation.
Service providers are the main place to bootstrap Laravel or can be interpreted as the main part of configuring applications.
Bootstrap in general is to register a component, including routes, event listeners, and middleware, and bindings containers.
After all the processes have been carried out and you have understood the structure of the Laravel folder, we will now discuss the basic configuration that is recommended to run.
1. Secure Data Using Application Key
After installing Laravel, the next step you need to run is to secure the data first. If this key is not applied, user activity and the following data will not be safe. This security can be done by changing the application key to a random string.
How , you can execute the command php artisan key: generate. There will be .env file in the root directory that contains the string with a length of 32 characters. If it's not there, you can copy the .env.example file to an .env file.
2. Settings for Public Directories
In certain cases the web server cannot directly call the index.php file which is in the Laravel public folder. So you need to direct the web server to call the document or web root to the public folder.
Please note, if you run Laravel on a local web server, then you need to change the permissions on the storage folder and bootstrap / cache to 777 with chmod.
$ chmod 777 -R / blog / storage
$ chmod 777 -R / blog / bootstrap / cache
The "blog" folder is the Laravel installation folder.
If this permission is set, you can access the index file without the need to run the "php artisan serve" command , but the folder must be on the web server folder.
3. Cache Settings
In order for the application to run quickly, you must set the cache on Laravel by using the config: cache command during the production process.
$ php artisan config: cache
4. Other ConfigurationsIf you want to adjust other configurations such as timezone & locale settings in config / app.php that you can adjust to the needs of the application.
All configuration files are in the config folder, so you can open the folder to find out what configurations are provided.
Get to Know the Mode Features on LaravelThe .env file is also used as a configuration file for several mode features in Laravel. Available modes such as develop and maintenance modes. Mode can be used when you make the application creation process from development to testing. When the mode feature is activated, the temporary application will be deactivated and the display will be replaced according to the current mode.
When you are trying to repair an application, it is more convenient if the application is disabled so that the end does not display an error when a problem occurs. In addition, if the application is not activated at all, visitors can see the error. This is certainly not good for you. Therefore, maintenance mode needs to be activated.
To activate maintenance mode, you can use the following command:
$ php artisan down
the maintenance mode page will appear in the application.
You can reactivate with the up command.
$ php artisan up
Display mode features you can set in the resources / views / errors folder .
Laravel is a fairly reliable framework. However, its application can confuse users who are still unfamiliar with programming. In fact, Laravel offers simplicity in writing code, in addition to security features that are different from other frameworks. If you want to learn a framework that is easier, we suggest not to directly learn Laravel.
There are several modes that you can use in the application development process. This mode helps display information if the website is in the process of being improved.
If you are a developer who likes neatness and simplicity with reliable performance, learn the Laravel tutorial. Laravel is able to make your system more sophisticated and secure.
Hopefully this basic Laravel tutorial article can help you in developing your programming skills. If you have any input, feel free to comment or subscribe to our latest tutorial.