-
-
Notifications
You must be signed in to change notification settings - Fork 370
Local Development (Arch Linux)
A guide by EkoNesLeg
This guide outlines the steps to set up UNIT3D using Laravel Sail on Arch Linux. While the guide highlights the use of Arch Linux, the instructions can be adapted to other environments.
Important
This guide is intended for local development environments only and is not suitable for production deployment.
For local development, HTTP is commonly used instead of HTTPS. To prevent mixed content issues, adjust your .env
file as follows:
-
Modify the
.env
Config:-
Open your
.env
file in the root directory of your UNIT3D project. -
Add or modify the following environment variables:
DB_USERNAME=unit3d # The username can be anything except `root` SESSION_SECURE_COOKIE=false # Disables secure cookies CSP_ENABLED=false # Disables Content Security Policy HSTS_ENABLED=false # Disables Strict Transport Security
-
Ensure Docker and Docker Compose are installed, as they are required for managing the Dockerized development environment provided by Laravel Sail.
Refer to the Arch Linux Docker documentation and install the necessary packages:
sudo pacman -S docker docker-compose
Clone the UNIT3D repository to your local environment:
-
Navigate to your chosen workspace directory:
cd ~/PhpstormProjects
-
Clone the repository:
git clone [email protected]:HDInnovations/UNIT3D-Community-Edition.git
-
Change to the project’s root directory:
cd ~/PhpstormProjects/UNIT3D-Community-Edition
-
Install Composer dependencies:
Run the following command to install the PHP dependencies:
composer install
-
Switch to Branch 8.x.x:
Before starting Docker, switch to the
8.x.x
branch:git checkout 8.x.x
-
Start the Docker environment using Laravel Sail:
./vendor/bin/sail up -d
Generate a new APP_KEY
in the .env
file for encryption:
./vendor/bin/sail artisan key:generate
Note: If you are importing a database backup, make sure to set the APP_KEY
in the .env
file to match the key used when the backup was created.
Initialize your database with sample data by running migrations and seeders:
./vendor/bin/sail artisan migrate:fresh --seed
Important
This operation resets your database and seeds it with default data. Avoid running this in a production environment.
Prepare your database with the initial schema and data. Make sure you have a database dump file, such as prod-site-backup.sql
.
Import your database dump into MySQL within the Docker environment:
./vendor/bin/sail mysql -u root -p unit3d < prod-site-backup.sql
Note: Ensure that the APP_KEY
in the .env
file matches the key used in your deployment environment for compatibility.
Manage Node.js dependencies and compile assets within the Docker environment:
./vendor/bin/sail bun install
./vendor/bin/sail bun run build
If needed, refresh the Node.js environment:
./vendor/bin/sail rm -rf node_modules && bun pm cache rm && bun install && bun run build
Optimize the application's performance by setting up the cache:
./vendor/bin/sail artisan set:all_cache
Apply new configurations or restart the environment by toggling the Docker environment:
./vendor/bin/sail restart && ./vendor/bin/sail artisan queue:restart
-
Permissions: Use
sudo
cautiously to avoid permission conflicts, particularly with Docker commands that require elevated access.
This section provides a reference for managing and interacting with UNIT3D using Laravel Sail.
-
Start Environment:
./vendor/bin/sail up -d
Starts Docker containers in detached mode.
-
Stop Environment:
./vendor/bin/sail down
Stops and removes Docker containers.
-
Restart Environment:
./vendor/bin/sail restart
Applies changes by restarting the Docker environment.
-
Install Composer Dependencies:
./vendor/bin/sail composer install
Installs PHP dependencies defined in
composer.json
. -
Update Composer Dependencies:
./vendor/bin/sail composer update
Updates PHP dependencies defined in
composer.json
.
-
Run Migrations:
./vendor/bin/sail artisan migrate
Executes database migrations.
-
Seed Database:
./vendor/bin/sail artisan db:seed
Seeds the database with predefined data.
-
Refresh Database:
./vendor/bin/sail artisan migrate:fresh --seed
Resets and seeds the database.
-
Cache Configurations:
./vendor/bin/sail artisan set:all_cache
Clears and caches configurations for performance.
-
Install NPM Dependencies:
./vendor/bin/sail bun install
Installs Node.js dependencies.
-
Compile Assets:
./vendor/bin/sail bun run build
Compiles CSS and JavaScript assets.
-
MySQL Interaction:
Opens MySQL CLI for database interaction.
./vendor/bin/sail mysql -u root -p
-
Restart Queue Workers:
Restarts queue workers after changes.
./vendor/bin/sail artisan queue:restart
-
View Logs:
./vendor/bin/sail logs
Displays Docker container logs.
-
Run PHPUnit (PEST) Tests:
./vendor/bin/sail artisan test
Runs PEST tests for the application.