Added laravel-init
This commit is contained in:
41
laravel-init
Executable file
41
laravel-init
Executable file
@@ -0,0 +1,41 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Current user.
|
||||
ME=$(whoami)
|
||||
|
||||
# Use PHP composer to check if the project requires Laravel framework and quit if not.
|
||||
if ! composer show | grep -q "laravel/framework"; then
|
||||
echo "This project does not require Laravel framework. Exiting."
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Show the version of Laravel installed.
|
||||
LARAVEL_VERSION=$(composer show --format=json | jq -r '.packages[]? | select(.name == "laravel/framework") | .version')
|
||||
echo "Laravel version: $LARAVEL_VERSION"
|
||||
|
||||
# Create required empty directories and add .gitignore to each of them:
|
||||
DIRECTORIES=(
|
||||
"storage/framework/cache"
|
||||
"storage/framework/sessions"
|
||||
"storage/framework/views/twig"
|
||||
"storage/app"
|
||||
"storage/logs"
|
||||
"storage/reports"
|
||||
"bootstrap/cache"
|
||||
)
|
||||
|
||||
for dir in "${DIRECTORIES[@]}"; do
|
||||
# Create directory if it doesn't exist
|
||||
if [ ! -d "$dir" ]; then
|
||||
mkdir -p "$dir"
|
||||
echo "Created directory: $dir"
|
||||
fi
|
||||
|
||||
# Add .gitignore file with !.gitignore content
|
||||
if [ ! -f "$dir/.gitignore" ]; then
|
||||
echo "!.gitignore" > "$dir/.gitignore"
|
||||
echo "Created .gitignore in: $dir"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Laravel project directory initialized."
|
||||
Reference in New Issue
Block a user