This project provides a Bash script to automate the setup of local development environments using Laradock and Apache2. It simplifies the creation of project directories, VirtualHost configurations, and domain setup in the hosts file, ensuring a streamlined and efficient workflow for developers.
- Automatically detects or sets the system language.
- Creates project directories with a predefined structure.
- Configures Apache2 VirtualHosts dynamically.
- Updates the hosts file with the new domain, organized by categories.
- Restarts Apache2 in the Laradock environment to apply changes.
- Provides user-friendly prompts and feedback messages.
- Operating System: Linux or macOS with Bash support.
- Dependencies:
- Docker and Laradock installed and configured.
- Apache2 available in the Laradock environment.
sed
andfind
utilities installed.
- Permissions: Must be run as root or with
sudo
to modify system files like/etc/hosts
.
- Languages: Supports English (
en_US
) and Portuguese (pt_BR
). - Environment: Designed for use with Laradock and Apache2.
The script includes several variables that can be customized to fit your environment:
language
: Default language for messages. Options:"en_US"
,"pt_BR"
.auto_detect_language
: Automatically detect the system language. Options:true
,false
.laradock_path
: Path to the Laradock directory. Example:"/home/user/Laradock"
.docker_apache2_restart_command
: Command to restart Apache2 in Laradock. Default:"docker restart laradock_apache2_1"
.apache_path
: Path to the Apache2 configuration directory. Example:"$laradock_path/apache2/sites"
.projects_path
: Path to the directory where projects will be created. Example:"/home/user/Projects"
.host_file
: Path to the hosts file. Default:"/etc/hosts"
.category_slug
: Identifier for categories in the hosts file. Default:"##CATEGORY:CAT_NAME_HERE##"
.default_categories
: List of default categories for organizing projects. Example:("Tests" "OpenSource" "Saas")
.virtual_host_template
: Template for creating Apache2 VirtualHost configurations.
- Clone this repository to your local machine.
- Open the script and adjust the configurable variables to match your environment.
- Run the script with
sudo
or as root:sudo ./laradock_project_creator.sh
- Follow the prompts to create a new project.
To simplify running the script, you can create a shell alias. Follow these steps:
-
Open your shell configuration file (e.g.,
~/.bashrc
or~/.zshrc
) in a text editor(nano, gedit, xed(Linux Mint), subl(Sublime Text), code(VsCode)):nano ~/.bashrc
Or for Zsh:
nano ~/.zshrc
-
Add the following line to create an alias for the script:
alias laradock-create="/path/to/laradock_project_creator.sh"
Replace
/path/to/
with the full path to the script. -
Save the file and reload your shell configuration:
source ~/.bashrc
Or for Zsh:
source ~/.zshrc
-
(Optional) If you encounter issues running the alias with
sudo
, you may need to create an alias forsudo
itself. Add the following line to your shell configuration file:alias sudo="sudo "
This ensures that
sudo
works correctly with aliases. -
Now you can run the script using the alias:
sudo laradock-create
This project is licensed under the MIT License. See the LICENSE file for details.