Skip to content

Commit e377868

Browse files
Initial commit
0 parents commit e377868

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+13245
-0
lines changed

.devcontainer/Dockerfile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Dockerfile for Laravel Dev Container (GitHub Codespaces)
2+
FROM mcr.microsoft.com/devcontainers/php:8.2
3+
4+
# Install system dependencies and PHP extensions
5+
RUN apt-get update && \
6+
apt-get install -y \
7+
git \
8+
unzip \
9+
libpng-dev \
10+
libonig-dev \
11+
libxml2-dev \
12+
libzip-dev \
13+
libcurl4-openssl-dev \
14+
libsqlite3-dev \
15+
libreadline-dev \
16+
libxslt1-dev \
17+
libpq-dev \
18+
curl \
19+
zip \
20+
default-mysql-client && \
21+
docker-php-ext-install pdo_mysql mbstring xml zip bcmath
22+
23+
# Install latest Node.js (LTS version) and npm
24+
RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \
25+
apt-get install -y nodejs
26+
27+
# Install Composer
28+
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
29+
30+
# Set working directory
31+
WORKDIR /workspaces/codespaces-template-laravel-priv
32+
33+
# Expose port 8000 for Laravel
34+
EXPOSE 8000

.devcontainer/devcontainer.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "Laravel Dev Container",
3+
"dockerComposeFile": "docker-compose.yml",
4+
"service": "app",
5+
"workspaceFolder": "/workspaces/codespaces-template-laravel-priv",
6+
"remoteUser": "vscode",
7+
"forwardPorts": [8000],
8+
"postCreateCommand": ".devcontainer/post-create.sh",
9+
"customizations": {
10+
"vscode": {
11+
"extensions": [
12+
"onecentlin.laravel-blade",
13+
"onecentlin.laravel5-snippets",
14+
"bmewburn.vscode-intelephense-client"
15+
]
16+
}
17+
}
18+
}

.devcontainer/docker-compose.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
version: '3.8'
2+
3+
services:
4+
app:
5+
build:
6+
context: .
7+
dockerfile: Dockerfile
8+
container_name: laravel-app
9+
user: vscode
10+
volumes:
11+
- ..:/workspaces/codespaces-template-laravel-priv:cached
12+
ports:
13+
- "8000:8000"
14+
environment:
15+
- APP_ENV=local
16+
- APP_DEBUG=true
17+
depends_on:
18+
- mysql
19+
20+
mysql:
21+
image: mysql:8.0
22+
container_name: mysql
23+
restart: unless-stopped
24+
environment:
25+
MYSQL_ROOT_PASSWORD: root
26+
MYSQL_DATABASE: laravel
27+
MYSQL_USER: laravel
28+
MYSQL_PASSWORD: secret
29+
ports:
30+
- "3306:3306"
31+
volumes:
32+
- mysql-data:/var/lib/mysql
33+
34+
volumes:
35+
mysql-data:

.devcontainer/post-create.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
3+
echo '=== Starting Laravel Setup ===' > /workspaces/codespaces-template-laravel-priv/setup-status.log
4+
composer install && echo '✓ PHP Dependencies installed' >> /workspaces/codespaces-template-laravel-priv/setup-status.log
5+
npm install && echo '✓ Frontend Dependencies installed' >> /workspaces/codespaces-template-laravel-priv/setup-status.log
6+
7+
if [ ! -f .env ]; then
8+
cp .env.example .env
9+
sed -i 's/^DB_CONNECTION=.*/DB_CONNECTION=mysql/' .env
10+
sed -i 's/^# DB_HOST=.*/DB_HOST=mysql/' .env
11+
sed -i 's/^# DB_PORT=.*/DB_PORT=3306/' .env
12+
sed -i 's/^# DB_DATABASE=.*/DB_DATABASE=laravel/' .env
13+
sed -i 's/^# DB_USERNAME=.*/DB_USERNAME=laravel/' .env
14+
sed -i 's/^# DB_PASSWORD=.*/DB_PASSWORD=secret/' .env
15+
php artisan key:generate > /dev/null && echo '✓ Environment configured' >> /workspaces/codespaces-template-laravel-priv/setup-status.log
16+
else
17+
echo '✓ Using existing environment' >> /workspaces/codespaces-template-laravel-priv/setup-status.log
18+
fi
19+
20+
echo '⏳ Waiting for database...' >> /workspaces/codespaces-template-laravel-priv/setup-status.log
21+
for i in {1..45}; do
22+
mysql -h mysql -u laravel -psecret -e 'SELECT 1' &> /dev/null && {
23+
echo '✓ Database connection established' >> /workspaces/codespaces-template-laravel-priv/setup-status.log
24+
break
25+
}
26+
sleep 2
27+
done
28+
29+
echo '⏳ Checking database readiness...' >> /workspaces/codespaces-template-laravel-priv/setup-status.log
30+
mysql -h mysql -u laravel -psecret -e 'CREATE DATABASE IF NOT EXISTS laravel' &> /dev/null
31+
sleep 3
32+
php artisan config:clear > /dev/null
33+
php artisan cache:clear > /dev/null
34+
echo '⏳ Verifying database...' >> /workspaces/codespaces-template-laravel-priv/setup-status.log
35+
if php artisan migrate:status 2> /dev/null | grep -q 'Migration table not found' || php artisan migrate:status 2> /dev/null | grep -q 'No migrations found'; then
36+
echo '⏳ Running initial migrations...' >> /workspaces/codespaces-template-laravel-priv/setup-status.log
37+
php artisan migrate --no-interaction --force >> /workspaces/codespaces-template-laravel-priv/setup-status.log 2>&1 && echo '✓ Initial migrations completed' >> /workspaces/codespaces-template-laravel-priv/setup-status.log || echo '✗ Migration failed - see details above' >> /workspaces/codespaces-template-laravel-priv/setup-status.log
38+
else
39+
echo '⏳ Running migrations (if needed)...' >> /workspaces/codespaces-template-laravel-priv/setup-status.log
40+
php artisan migrate --no-interaction --force >> /workspaces/codespaces-template-laravel-priv/setup-status.log 2>&1 && echo '✓ Migrations up to date' >> /workspaces/codespaces-template-laravel-priv/setup-status.log || echo '✗ Migration failed - see details above' >> /workspaces/codespaces-template-laravel-priv/setup-status.log
41+
fi
42+
echo '=== Setup Complete! ===' >> /workspaces/codespaces-template-laravel-priv/setup-status.log

.editorconfig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_size = 4
7+
indent_style = space
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[*.{yml,yaml}]
15+
indent_size = 2
16+
17+
[docker-compose.yml]
18+
indent_size = 4

.env.example

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
APP_NAME=Laravel
2+
APP_ENV=local
3+
APP_KEY=
4+
APP_DEBUG=true
5+
APP_URL=http://localhost
6+
7+
APP_LOCALE=en
8+
APP_FALLBACK_LOCALE=en
9+
APP_FAKER_LOCALE=en_US
10+
11+
APP_MAINTENANCE_DRIVER=file
12+
# APP_MAINTENANCE_STORE=database
13+
14+
PHP_CLI_SERVER_WORKERS=4
15+
16+
BCRYPT_ROUNDS=12
17+
18+
LOG_CHANNEL=stack
19+
LOG_STACK=single
20+
LOG_DEPRECATIONS_CHANNEL=null
21+
LOG_LEVEL=debug
22+
23+
DB_CONNECTION=sqlite
24+
# DB_HOST=127.0.0.1
25+
# DB_PORT=3306
26+
# DB_DATABASE=laravel
27+
# DB_USERNAME=root
28+
# DB_PASSWORD=
29+
30+
SESSION_DRIVER=database
31+
SESSION_LIFETIME=120
32+
SESSION_ENCRYPT=false
33+
SESSION_PATH=/
34+
SESSION_DOMAIN=null
35+
36+
BROADCAST_CONNECTION=log
37+
FILESYSTEM_DISK=local
38+
QUEUE_CONNECTION=database
39+
40+
CACHE_STORE=database
41+
# CACHE_PREFIX=
42+
43+
MEMCACHED_HOST=127.0.0.1
44+
45+
REDIS_CLIENT=phpredis
46+
REDIS_HOST=127.0.0.1
47+
REDIS_PASSWORD=null
48+
REDIS_PORT=6379
49+
50+
MAIL_MAILER=log
51+
MAIL_SCHEME=null
52+
MAIL_HOST=127.0.0.1
53+
MAIL_PORT=2525
54+
MAIL_USERNAME=null
55+
MAIL_PASSWORD=null
56+
MAIL_FROM_ADDRESS="hello@example.com"
57+
MAIL_FROM_NAME="${APP_NAME}"
58+
59+
AWS_ACCESS_KEY_ID=
60+
AWS_SECRET_ACCESS_KEY=
61+
AWS_DEFAULT_REGION=us-east-1
62+
AWS_BUCKET=
63+
AWS_USE_PATH_STYLE_ENDPOINT=false
64+
65+
VITE_APP_NAME="${APP_NAME}"

.gitattributes

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
* text=auto eol=lf
2+
3+
*.blade.php diff=html
4+
*.css diff=css
5+
*.html diff=html
6+
*.md diff=markdown
7+
*.php diff=php
8+
9+
/.github export-ignore
10+
CHANGELOG.md export-ignore
11+
.styleci.yml export-ignore

.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
*.log
2+
.DS_Store
3+
.env
4+
.env.backup
5+
.env.production
6+
.phpactor.json
7+
.phpunit.result.cache
8+
/.fleet
9+
/.idea
10+
/.nova
11+
/.phpunit.cache
12+
/.vscode
13+
/.zed
14+
/auth.json
15+
/node_modules
16+
/public/build
17+
/public/hot
18+
/public/storage
19+
/storage/*.key
20+
/storage/pail
21+
/vendor
22+
Homestead.json
23+
Homestead.yaml
24+
Thumbs.db

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 jfullstackdev
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Laravel Template for GitHub Codespaces
2+
3+
![sample image](image.png)
4+
5+
A ready-to-use Laravel development environment, optimized for GitHub Codespaces.
6+
This template provides a seamless, zero-setup experience for Laravel development
7+
in the cloud.
8+
9+
## Dev Container Config Overview
10+
11+
- **Pre-configured Dev Container**: Uses Docker Compose to orchestrate PHP 8.2
12+
(LTS), Node.js 18 (LTS), and MySQL 8.0 (LTS) services.
13+
- **MySQL Pre-installed and Running**: MySQL 8.0 is included as a service in the
14+
dev container—no need to install or configure a database server manually.
15+
- **VS Code Extensions**: Installs recommended extensions for Laravel, PHP, and
16+
Docker development.
17+
- **Automated Setup**: Handles dependency installation, environment setup, and
18+
database migrations automatically on first launch.
19+
- **Correct Permissions**: Ensures storage and cache directories are writable for
20+
Laravel.
21+
22+
## Laravel Standard Installation
23+
24+
- **Laravel Version**: 12.19.3 (latest as of July 2025)
25+
- **Standard Structure**: Includes all default Laravel directories and files
26+
(`app/`, `config/`, `database/`, `routes/`, etc.)
27+
- **No Custom Packages**: Clean install, ready for your customization.
28+
29+
## Out-of-the-Box Features
30+
31+
- **Automated Dependency Installation**: Runs `composer install` and
32+
`npm install` on first start.
33+
- **Automatic `.env` Setup**: Copies `.env.example` to `.env` and configures
34+
database credentials for the Codespace environment.
35+
- **Database Prepared Automatically**: The MySQL database is created, ready, and
36+
all migrations are run for you—no manual steps needed.
37+
- **Pre-installed VS Code Extensions**: Includes extensions for Blade, PHP
38+
Intelephense, Laravel snippets, and more.
39+
- **Writable Storage/Cache**: Ensures `storage/` and `bootstrap/cache/` are
40+
writable by the application.
41+
42+
## Getting Started in Codespaces
43+
44+
1. You can get started with this template in several ways:
45+
- **Open a Codespace directly from GitHub:**
46+
- If this repository is public, you can click the "Code" button on the
47+
repo page and select "Create codespace on main" (or another branch).
48+
No need to fork or clone first — GitHub will automatically provision a
49+
Codespace with the repo contents and devcontainer setup.
50+
- **Fork the repository:**
51+
- If you want your own copy of the repository (for making changes or
52+
keeping your own Codespace), fork it on GitHub, then open a Codespace
53+
from your fork.
54+
- **Manual setup using the devcontainer:**
55+
- You may also copy the `.devcontainer` folder/configuration to another
56+
project or environment to reuse the same development setup. This is
57+
only recommended if you know what you are doing — your project may not
58+
work at all if the environment is not compatible or is missing
59+
required services.
60+
61+
2. **Wait for Setup**: The container will build, dependencies will be installed,
62+
and the database will be prepared automatically. As soon as the Codespace is
63+
available, you can open the `setup-status.log` file in the project root to
64+
watch the automated setup progress and verify it completed successfully.
65+
3. **Start the Laravel Development Server**: Run the following command in the
66+
terminal to start the app and make it accessible:
67+
68+
```bash
69+
php artisan serve --host=0.0.0.0 --port=8000
70+
```
71+
4. **Open in Browser**: Once the app is running, a pop-up may appear in
72+
Codespaces with an "Open in Browser" button for port 8000. If you miss it,
73+
you can always go to the "Ports" tab, find port 8000, and click "Open in
74+
Browser". (The URL will be a Codespaces-specific address, not localhost.)
75+
76+
## License
77+
78+
This template is provided under the MIT License. See [LICENSE](LICENSE) for
79+
full details.

0 commit comments

Comments
 (0)