In the first time I got acquainted with Laravel, I used to clone a project many times from GitHub to the computer but then struggled to know how to operate the system. Opening up the browser, I only saw the error.
If you’ve ever experienced the same situation, this article is for you.
This article will list the basic steps to do after cloning a Laravel project from GitHub to the device. This is also a part of additional support for you who are watching the series Laravel File Upload. But I share on the blog, the room when you download the source code but do not know how to configure.
Before starting, ask your computer to pre-install the Laravel development environment.
1. Clone Project from GitHub
First, clone the project source code from GitHub. For example, I will clone branch part-1-basic-uploadthat belongs
to Laravel file upload
git clone --single-branch --branch part-1-basic-upload https://github.com/10h30/laravel-file-upload-series.git
cd laravel-file-upload-series
Code language: Bash (bash)
If you open the web browser, access http://laravel-file-upload-series
Will see an error Warning: require(......vendor/autoload.php): Failed to open stream....
The next steps need to be taken for the project to be ready to operate
2. Create a .env file from the sample file
Laravel uses file .env
To configure the environment (database, mail, app key …). After clone, we need to create a file .env
:
cp .env.example .env
Code language: CSS (css)
3. Install PHP libraries with Composer
Laravel uses Composer to manage PHP libraries. Need to install PHP libraries with Composer
composer install
Code language: Nginx (nginx)
In many cases, because the package is too old no longer exists, we will use this command
composer update
Code language: Nginx (nginx)
but
4. Create Application Key
Laravel requires APP_KEY
To encrypt data. Create a key with command:
php artisan key:generate
Code language: CSS (css)
5. Install Frontend libraries
If the project uses Laravel Mix, Vite or other Frontend Tools, we need to run more
npm install
Code language: Nginx (nginx)
6. Database configuration
Open the file .env
And update the database connection information suitable to your local environment:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=name_database
DB_USERNAME=root
DB_PASSWORD=
Then run migration to create a table
php artisan migrate
Code language: Nginx (nginx)
If the project has sample data (Seeder), run:
php artisan db:seed
Code language: CSS (css)
Or combine both:
php artisan migrate --seed
Code language: Nginx (nginx)
7. Create a symbolic link for Storage (if any)
If the project uses uploading and saving the file (as in the Laravel File Upload series), you need to create a symbolic link:
php artisan storage:link
Code language: CSS (css)
8. Conclusion
Above are the basic steps to be done after clone a Laravel project from GitHub to Local. Once you are familiar with this process, you can write automation script to save time and avoid errors when manipulating manual. I will share how to automate the use of bash script in the next article.
Hopefully this article is useful for you, especially if you are watching the articles in the series Laravel file upload. If you have any questions during the setup process, leave a comment below, I will support it as possible.
Comment Policy: We truly value your comments and appreciate the time you take to share your thoughts and feedback with us.
Note: Comments that are identified as spam or purely promotional will be removed.
To enhance your commenting experience, consider creating a Gravatar account. By adding an avatar and using the same e-mail here, your comments will feature a unique and recognizable avatar, making it easier for other members to identify you.
Please use a valid e-mail address so you can receive notifications when your comments receive replies.