I found a laravel project on GitHub but the problem is I am unable to run it. Can anyone help me set up the laravel project cloned from GitHub?
Clone or download the project from GitHub. If you want to clone then make sure you have git installed on your computer. Else download and extract the project.
git clone <project>
You need to open your project folder or cd into your project from the command line. It’s better you use the command line because the rest of the steps are in the command line.
Make sure you have composer installed on your computer. In most cases, you will not get any dependencies along with the GitHub project. You need to install them after you clone the project from GitHub. Run the following command in the command line.
You will see composer will start installing the necessary files. You can see which dependencies are installed by opening composer.json
This is not necessary that your project has npm dependencies but if it has then you need to install it as well. First, check if your project folder root has a package.json file. If it does then you may need to install the dependencies. Make sure you have NodeJs installed on your computer then run the following command.
For security reasons, you will not get a .env file with the GitHub project. You need to create one from .env.example and fill up the necessary information. Use the following command to copy the .env file form .env.example
cp .env.example .env
Now update the database info or other details in the .env file. e.g.
DB_USERNAME , and
Laravel requires an app encryption key which is used to encode cookies to password hashes and more. An encryption key is generally a randomly generated string stored in your .env file. To generate the app encryption key use the following command.
php artisan key:generate
As you already update the database connection details in .env file you can now migrate the database with the following command.
php artisan migrate
If the project has a seeding file then you need to seed the data. This is normally to insert starter or dummy data into the database. If your project doesn’t have any seed file then don’t need to follow this step. Use the following command to seed your database.
php artisan db:seed
All should be set by now. You can run laravel development server with the following command.
php artisan serve
Now visit the following link to see the project