This documentation provides step-by-step instructions to install and configure the project for the first time. The installation script ensures the environment is correctly set up with necessary dependencies, configurations, and database creation.
Make sure you have the following installed and configured on your system:
- PHP: Version compatible with Laravel.
- Composer: For managing PHP dependencies.
- MySQL/MariaDB: For database management.
- Node.js and npm: For frontend dependencies and build.
- Git: For version control.
- Supervisor: For process management (if needed).
git clone <repository-url> project-directory
cd project-directory
Replace <repository-url>
with the actual repository URL.
Run the script:
./bin/install
-
Database Creation:
- Checks if the database exists.
- If not, it creates a database using the directory name converted to snake_case.
Example: If the project directory is
loop-tag
, the database will be namedloop_tag
. -
Environment Configuration:
- Updates
.env.example
with:- APP_NAME in Title Case (e.g.,
Loop Tag
). - DB_DATABASE in snake_case (e.g.,
loop_tag
).
- APP_NAME in Title Case (e.g.,
- Copies
.env.example
to.env
and generates an application key if.env
does not exist.
- Updates
-
Composer Dependencies Installation:
- Installs Composer dependencies if the
vendor/
directory is missing. - Runs
update-dependencies
script if present.
- Installs Composer dependencies if the
-
NPM Dependencies Installation:
- Installs and builds npm dependencies if
node_modules/
is not available. - Commits changes to the
public/
directory if modified after the build.
- Installs and builds npm dependencies if
-
Supervisor Configuration Update:
- Updates
.config/supervisord.ini
with:- Command path:
command=php /var/www/<project-name>/artisan horizon
(kebab-case directory name). - Log file path:
stdout_logfile=/var/log/supervisor/<project-name>-horizon.log
(kebab-case log file).
- Command path:
- Commits the changes to
.config/supervisord.ini
if any updates are made.
- Updates
-
README.md Update:
- Replaces:
- The default GitHub URL with the project’s remote URL.
- "Project Template" with the project name in Title Case.
- Commits changes to
README.md
if modified.
- Replaces:
Once the installation is complete, the environment is ready. You can:
-
Start the Laravel development server:
php artisan serve
project-directory/
├── .config/
│ └── supervisord.ini # Supervisor configuration file
├── .env.example # Environment configuration template
├── README.md # Project documentation
├── .config/
│ └── install # Installation script
├── vendor/ # Composer dependencies (auto-installed)
├── node_modules/ # NPM dependencies (auto-installed)
└── public/ # Public assets (build generated)
-
Database Credentials: Set your MySQL credentials using environment variables:
export DB_USERNAME='your-username' export DB_PASSWORD='your-password' export DB_HOST='localhost'
-
Supervisor Configuration: Adjust
.config/supervisord.ini
to meet your requirements if needed.
-
Permission Issues: Ensure the script has execute permissions:
chmod +x install.sh
-
Database Access Error: Verify that the MySQL credentials are correct and the MySQL service is running:
sudo systemctl start mysql
-
Dependency Installation Failure: Ensure Composer and npm are installed:
composer --version npm --version
-
Supervisor Issues: If Horizon doesn’t start, check the Supervisor logs:
tail -f /var/log/supervisor/<project-name>-horizon.log
This script automates the project setup by:
- Creating necessary configurations.
- Installing dependencies.
- Building the frontend.
- Setting up Supervisor and database connections.
If everything is configured correctly, the project will be ready to use. If you encounter any issues, refer to the troubleshooting section or consult the README.md for more details.