Initializing REST API project in Laravel
In the previous post we designed the whole REST API endpoints with database structure. This post we will use to show how to start PHP Laravel project, prepare database schema and generate all needed resources to phisically build fully working Web API.
Create in your operation system new directory and name it bookingsystem.
Open your best editor like visual studio code and in the command line type:
The command will generate standard structure for Laravel project. This is starting point for REST API.
During project installation you should see that lots of packages are downloaded for final Laravel project setup.
When project is generated you should have the standard folders structure of Laravel project. If you want to read more about it let’s go to my post about generating standard Laravel project in PHP where I explained in details the project structure.
You can run locally your new website using command:
When you run the command under the url http://localhost:8000 you will see default Laravel greeting site. If you made something wrong you probably has wrong version of PHP or uncorrectly installed laravel project or wrong project version. Send me feedback in comments if any problems occur.
Setting database connection and structure
When project is correctly setup we need to type correct parameters for database connection. We need to find the file .env in the mail directory. Modify part of the file like in the listing below:
You should also create mysql database with the name bookingsystem_db, user name bookingsystem_user and password bookingsystem_pass like I wrote in the post about mysql database configuration.