Skip to content

Commit 0c0cdf5

Browse files
committed
added document
1 parent 16f4f1f commit 0c0cdf5

File tree

6 files changed

+5319
-4163
lines changed

6 files changed

+5319
-4163
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,8 @@
1818
/public/assets/
1919
/assets/vendor/
2020
###< symfony/asset-mapper ###
21+
22+
###> friendsofphp/php-cs-fixer ###
23+
/.php-cs-fixer.php
24+
/.php-cs-fixer.cache
25+
###< friendsofphp/php-cs-fixer ###

.php-cs-fixer.dist.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
$finder = (new PhpCsFixer\Finder())
4+
->in(__DIR__)
5+
->exclude('var')
6+
;
7+
8+
return (new PhpCsFixer\Config())
9+
->setRules([
10+
'@Symfony' => true,
11+
])
12+
->setFinder($finder)
13+
;

README.md

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
# Setup Guide for PHP 8.4 + Symfony 7.3 + SQLite on WSL2
2+
3+
This guide covers setting up PHP 8.4, Symfony 7.3, SQLite on WSL2 (Ubuntu),
4+
managing the project with GitHub, and running tests with GitHub Actions.
5+
6+
## Environment
7+
8+
- Windows 11 + WSL2 (Ubuntu)
9+
- PHP 8.4
10+
- Symfony 7.3
11+
- SQLite
12+
13+
---
14+
15+
## 1. Install PHP 8.4
16+
17+
```bash
18+
sudo add-apt-repository ppa:ondrej/php
19+
sudo apt update
20+
sudo apt install php8.4-cli php8.4-sqlite3 php8.4-curl php8.4-xml php8.4-mbstring php8.4-zip php8.4-intl php8.4-opcache
21+
```
22+
23+
Verify PHP installation:
24+
25+
```bash
26+
php -v
27+
```
28+
29+
---
30+
31+
## 2. Install Composer
32+
33+
```bash
34+
curl -sS https://getcomposer.org/installer | php
35+
sudo mv composer.phar /usr/local/bin/composer
36+
```
37+
38+
Verify Composer installation:
39+
40+
```bash
41+
composer --version
42+
```
43+
44+
---
45+
46+
## 3. Install Symfony CLI
47+
48+
```bash
49+
curl -1sLf 'https://dl.cloudsmith.io/public/symfony/stable/setup.deb.sh' | sudo -E bash
50+
sudo apt install symfony-cli
51+
```
52+
53+
Verify Symfony CLI installation:
54+
55+
```bash
56+
symfony -v
57+
```
58+
59+
---
60+
61+
## 4. Create Symfony Project
62+
63+
```bash
64+
symfony new my_project --version="7.3.*" --webapp
65+
cd my_project
66+
```
67+
68+
---
69+
70+
## 5. Configure SQLite
71+
72+
Edit `.env`:
73+
74+
```env
75+
DATABASE_URL="sqlite:///%kernel.project_dir%/var/data_%kernel.environment%.db"
76+
# DATABASE_URL="postgresql://app:!ChangeMe!@127.0.0.1:5432/app?serverVersion=16&charset=utf8"
77+
```
78+
79+
Create the database:
80+
81+
```bash
82+
php bin/console doctrine:database:create
83+
```
84+
85+
---
86+
87+
## 6. Run the Server
88+
89+
```bash
90+
symfony server:start
91+
```
92+
93+
Open `http://localhost:8000` in your browser to verify.
94+
95+
---
96+
97+
## 7. Set up GitHub Repository
98+
99+
Edit `.env.dev` to set a non-sensitive `APP_SECRET`:
100+
101+
```env
102+
APP_SECRET="THIS_IS_FOR_DEV_SO_NOT_REALLY_SECRET"
103+
```
104+
105+
Create a repository on GitHub and push your project:
106+
107+
```bash
108+
git init
109+
git branch -M main
110+
git add .
111+
git commit -m "Initial commit"
112+
git remote add origin git@github.com:<username>/<repo-name>.git
113+
git push -u origin main
114+
```
115+
116+
---
117+
118+
## 8. Configure GitHub Actions for Testing
119+
120+
Install PHP-CS-Fixer:
121+
122+
```bash
123+
composer require --dev friendsofphp/php-cs-fixer
124+
```
125+
126+
Create `.github/workflows/ci.yml` in your project root:
127+
128+
```yaml
129+
name: CI
130+
131+
on: [push, pull_request]
132+
133+
jobs:
134+
symfony-tests:
135+
runs-on: ubuntu-latest
136+
137+
steps:
138+
- uses: actions/checkout@v4
139+
140+
- name: Set up PHP 8.4
141+
uses: shivammathur/setup-php@v2
142+
with:
143+
php-version: "8.4"
144+
extensions: sqlite, intl, mbstring, xml, zip
145+
coverage: none
146+
147+
- name: Install dependencies
148+
run: composer install --prefer-dist --no-progress
149+
150+
- name: Check coding standards (optional)
151+
run: PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer fix --dry-run --diff
152+
153+
- name: Run tests (PHPUnit)
154+
run: vendor/bin/phpunit
155+
```
156+
157+
Currently, PHP-CS-Fixer does not officially support PHP 8.4, thus
158+
`PHP_CS_FIXER_IGNORE_ENV=1` is set to bypass version checks temporarily.
159+
160+
Commit and push your changes to trigger tests via GitHub Actions.
161+
162+
---
163+
164+
## 9. Run PHPUnit Tests
165+
166+
Symfony 7.3 includes PHPUnit 12 by default:
167+
168+
```bash
169+
php bin/phpunit
170+
```
171+
172+
Ensure all tests pass successfully.
173+
174+
---
175+
176+
Your Symfony setup on WSL2 is now complete, including GitHub management and
177+
automated testing with GitHub Actions.

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
}
9898
},
9999
"require-dev": {
100+
"friendsofphp/php-cs-fixer": "^3.75",
100101
"phpunit/phpunit": "^12.1",
101102
"symfony/browser-kit": "7.3.*",
102103
"symfony/css-selector": "7.3.*",

0 commit comments

Comments
 (0)