Setting up an Existing Laravel Project (Quick Commands)

26th, Feb 2024

Setting up an Existing Laravel Project (Quick Commands)
Prerequisites:
  • Git installed on your machine
  • Node.js and npm installed
  • A copy of your existing Laravel project source code

Step 1: Clone the Git Repository (If Applicable)
 
If your existing Laravel project is already in a Git repository, you can clone it by following these steps:
  1. Open your terminal.
  2. Navigate to the directory where you want to create the local Laravel project.
  3. Clone the Git repository to your local machine:
  4. git clone  

Alternatively, if you have a local copy of the project without Git, you can skip this step.

Step 2: Navigate to the Project Directory
  1. Open your terminal.
  2. Navigate into your existing Laravel project directory:
  3. cd  

Step 3: Install Composer Dependencies
  1. If your Laravel project uses Composer for PHP dependencies, run the following command to install the required PHP packages:
  2. composer install 

Step 4: Install NPM Dependencies
  1. If your Laravel project uses NPM for front-end dependencies, run the following command to install them:
  2. npm install 

Step 5: Configure Laravel Environment
  1. Copy the .env.example file to create a .env file:
  2. cp .env.example .env
  3. Generate an application key for Laravel:
  4. php artisan key:generate 
  5. Configure the database settings in the .env file to match your local development environment.

Step 6: Laravel Migrations
  1. If your Laravel project uses a database, run migrations to set up the database schema:
  2. php artisan migrate 

Step 7: Serve the PHP Application
  1. To serve the PHP application locally, use php artisan serve:
  2. php artisan serve 
  3. Your Laravel application should now be accessible at http://localhost:8000.

Step 8: Building Assets
 
Now, you can follow the appropriate steps to build assets depending on whether your project uses Webpack or Vite, as outlined in the previous responses:

For NPM with Webpack:
  1. Build the assets for styling locally:
  2. npm run dev 
  3. You can also watch for changes in your assets and rebuild when files are modified:
  4. npm run watch 

For NPM with Vite:
  1. Keep Vite running in development mode with hot-reloading:
  2. npm run dev 
  3. To create a production-ready build of your assets:
  4. npm run build 
Your existing Laravel project is now set up and running on your local machine, and assets are ready for development or testing. Enjoy working on your project!

If you are looking for a simple list please see below:
  1. Clone the Git Repository (If Applicable):
    • git clone
  2. Navigate to the Project Directory:
    • cd
  3. Install Composer Dependencies:
    • composer install
  4. Install NPM Dependencies:
    • npm install
  5. Configure Laravel Environment:
    • cp .env.example .env
    • php artisan key:generate
  6. Laravel Migrations (If Applicable):
    • php artisan migrate
  7. Serve the PHP Application:
    • php artisan serve
  8. Building Assets with NPM and Webpack:
    • Build: npm run dev
    • Watch: npm run watch
  9. Building Assets with NPM and Vite:
    • Development Mode: npm run dev
    • Production Build: npm run build

Join my newsletter

Stay up to date with the latest trends, blogs and portfolio projects.