Knowledge Base

How to Install Laravel

  • make sure your project already contains a composer.json file, Laravel cannot run or install dependencies without it.

Requirement: composer.json Must Exist

Before running any Composer or Laravel command:

  • Confirm that composer.json exists in the project root

  • Laravel uses this file to know:

    • Which packages to install

    • Which Laravel version to run

    • How the application should boot


Without composer.json, Laravel will not work


Installation Steps

1. Make Sure the App Is Registered in Laravel Toolkit

  • Plesk → Websites & Domains → Laravel

  • If not listed → Scan existing application


2. Install Dependencies Safely

Run Composer only if composer.json exists:

composer install --no-scripts

  • Installs dependencies
  • Prevents dangerous scripts from running

3. Run Laravel Commands Manually

  • After installation:

php artisan key:generate # Only if APP_KEY is missing php artisan optimize:clear

Do not run migrations unless you know what they do.


4. Fix PHPUnit Issues (If Needed)

composer require phpunit/phpunit:^9.6 --dev


5. Set the Correct Document Root

In Plesk:

  • httpdocs/public

Never change the project structure.


6. Set Safe Permissions

chmod -R 775 storage bootstrap/cache


When Is It Safe to Delete vendor or composer.lock?

Only if dependencies are broken and composer.json is present:

rm -rf vendor composer.lock composer install --no-scripts

This does NOT delete:

  • .env

  • Database

  • Uploaded files


Summary

  • composer.json must exist first

  • Never delete .env

  • Use composer install --no-scripts

  • Avoid blind migrations

  • Use PHP 8.1

  • Document root must be public

Please rate this article to help us improve our Knowledge Base.

0 0