What is Laravel?
Laravel is a free framework for PHP. PHP is a language used to build websites. A framework is a ready-made toolbox. Instead of building login, routing and database code from nothing, you start with tools that are already there. Laravel is popular for web apps, shops and APIs.
What you need first
- PHP, at a version that your Laravel release supports.
- Composer. This is a tool that downloads PHP packages for you.
- A database such as MySQL, if your app stores data.
- SSH access if you install on a server. Ask Hostvento support whether your plan allows it.
Steps
- Open a terminal and check PHP:
php -v
This prints your PHP version.
- Check Composer:
composer --version
If it is missing, install it from the official Composer website.
- Go to the folder where you keep projects.
- Create a new Laravel project:
composer create-project laravel/laravel myapp
This downloads Laravel into a new folder called myapp. It may take a few minutes.
- Go into the folder:
cd myapp
- Start the built-in test server:
php artisan serve
Artisan is Laravel's own command tool. This starts a small test server.
- Open
http://127.0.0.1:8000in your browser. You should see the Laravel welcome page.
Set up the database
- Create an empty database and user in your control panel under MySQL Databases.
- Open the
.envfile in your project. It holds your settings. - Fill in
DB_DATABASE,DB_USERNAMEandDB_PASSWORD. - Build the tables:
php artisan migrate
Put it on hosting
Laravel's public entry point is the public folder. Your domain should point to that folder, not the project root. Keep the rest of the files outside the public web folder. Never share your .env file.
Quick recap
- Laravel is a PHP framework that saves you time.
- You need PHP and Composer.
- Run
composer create-project laravel/laravel myapp. - Test with
php artisan serve. - Point your domain at the
publicfolder.