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.
- The basis of using PHP
- The basis of the MVC Framework
However, you can try to slowly understand the basic Laravel tutorial or understanding framework. In this article we will try to provide light content so that people who are not familiar with programming can understand easily.
The installation process is carried out on a web server. You can use a VPS service provider such as Niagahoster 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.
- Web Server
- PHP> = 7.1.3
- Database Server
- PHP Extension Tokenizer
- OpenSSL PHP Extension
- PHP PDO Extension
- PHP Type Extension
- JSON PHP Extension
How to Install Laravel & Configuration
There 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 Laravel
Composer 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 blog
The 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_profile
and add rows
export PATH = ~ / .composer / vendor / bin: $ PATH
If 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 serve
The 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 Structure
When 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.
- app , this folder contains a core code consisting of five folders.
- Console , this folder contains all the Artisan commands made with the make: command.
- Exception , this folder contains all the exception handlers and this folder is good for adding classes that have been customized to handle exceptions given by the application.
- Http , this folder contains functions of controllers, middleware and requests .
- Providers , this folder contains all service providers for the application.
- bootstrap , this folder contains all bootstrap frameworks as well as configuration files.
- config , this folder contains all application configuration files.
- database , this folder contains all migration databases and seeds.
- resource , this folder contains raw assets such as LESS & Sass files, time settings, and language.
- routes , this folder contains all the routes defined in the application.
- storage, this folder contains App storage, such as file uploads, caches , and logs.
- the app
- tests , this folder contains all the test files.
- vendor , this folder contains all the dependency files .
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 Configurations
If 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 Laravel
The .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.
- The maintenance mode ( Maintenance 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.
Take Your Knowledge to the Next Level
- Find out what an ISO is and how to burn an ISO to DVD on Windows, Mac and Linux, the main burning programs. All the information here!
- So, you want to know how to update this Widevine Content Decryption module of Chrome component and how to fix it in Windows 10? Keep reading.
- You are listening to some of your favorite songs on Spotify, the music stops and you see the error: “Spotify can’t play this right now“.
- As you explore Reddit, you’ll also find videos that you might want to save. Here are some methods to download Reddit videos on phone or PC.
- Know How to Troubleshoot YouTube App If It Not Working on Android Mobile or iOS Device. Also checkout the alternatives for YouTube App.
- There are several ways to check the health of your hard drive on Windows 10. This article explains the best methods. check out the guide..
- Google Authenticator can be helpful, but it’s annoying that Google hasn’t yet created an official desktop app. Let’s explore the ways to do..
- One of the most common errors in Google Chrome is the dns_probe_finished_nxdomain or DNS Probe Finished NXDomain. Know how to fix this easily
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.
[ 1 ] Laravel Tutorial for Beginner: Create your First To-Do App in Laravel 5.4
[ 2 ] Laravel Installation – Basic Task List
[ 3 ] Learn Laravel Tutorial Absolute Beginner
[ 4 ] Laravel Installation Documentation