-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsetup-local-dev.sh
More file actions
executable file
·83 lines (68 loc) · 2.25 KB
/
Copy pathsetup-local-dev.sh
File metadata and controls
executable file
·83 lines (68 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
# Local Development Setup Script for CAPS Backend
# This script automates the setup of a local development environment
set -e # Exit on any error
echo "Setting up local development environment for CAPS backend..."
# Check if we're in the right directory
if [ ! -f "backend/composer.json" ]; then
echo "Error: This script must be run from the project root directory"
exit 1
fi
# Change to backend directory
cd backend
# Check if composer is installed
if ! command -v composer &> /dev/null; then
echo "Error: Composer is not installed"
exit 1
fi
# Check for PHP extensions required by Composer packages
missing_php_extensions=()
for extension in dom SimpleXML; do
if ! php -m | grep -qi "^${extension}$"; then
missing_php_extensions+=("$extension")
fi
done
if [ ${#missing_php_extensions[@]} -gt 0 ]; then
php_version="$(php -r 'echo PHP_MAJOR_VERSION . "." . PHP_MINOR_VERSION;' 2>/dev/null || true)"
php_xml_package="php-xml"
if [ -n "$php_version" ]; then
php_xml_package="php${php_version}-xml"
fi
echo "Error: Missing PHP extension(s): ${missing_php_extensions[*]}"
echo "Composer dependencies require the PHP XML extensions DOM and SimpleXML."
echo ""
echo "On Debian/Ubuntu, install them with:"
echo " sudo apt install ${php_xml_package}"
echo ""
echo "Then verify with:"
echo " php -m | grep -E '^(dom|SimpleXML)$'"
exit 1
fi
# Install PHP dependencies
echo "Installing PHP dependencies..."
composer install
# Create SQLite database directory if it doesn't exist
echo "Setting up database..."
mkdir -p tmp
touch tmp/caps.sqlite
chmod 777 tmp/caps.sqlite
# Copy example environment file
echo "Setting up environment configuration..."
if [ ! -f ".env" ]; then
cp example.env .env
echo "Created .env file from example.env"
else
echo ".env file already exists"
fi
# Run database migrations
echo "Running database migrations..."
bin/cake migrations migrate
# Create admin user
echo "Creating admin user..."
bin/cake grant-admin admin --force --password admin
echo "Local development environment setup complete!"
echo ""
echo "To start the development server, run:"
echo " $(pwd)/bin/cake server"
echo ""
echo "The application will be available at http://localhost:8765"