-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sylvain Blondeau
authored
Dec 7, 2022
0 parents
commit e09c771
Showing
72 changed files
with
18,481 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# This file is an automatic configuration of some points for this project | ||
# In order for your IDE to handle this file, you probably must install an plugin to it. | ||
# Just look for somthing like "editorconfig" plugin. Then, you have nothing else to do :). | ||
# https://EditorConfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
end_of_line = lf | ||
charset = utf-8 | ||
tab_width = 4 | ||
indent_size = 4 | ||
indent_style = space | ||
|
||
[Makefile*] | ||
indent_style = tab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# In all environments, the following files are loaded if they exist, | ||
# the latter taking precedence over the former: | ||
# | ||
# * .env contains default values for the environment variables needed by the app | ||
# * .env.local uncommitted file with local overrides | ||
# * .env.$APP_ENV committed environment-specific defaults | ||
# * .env.$APP_ENV.local uncommitted environment-specific overrides | ||
# | ||
# Real environment variables win over .env files. | ||
# | ||
# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES. | ||
# | ||
# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2). | ||
# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration | ||
|
||
###> symfony/framework-bundle ### | ||
APP_ENV=dev | ||
APP_SECRET=6ac5f54399d6b50ce81601093922741a | ||
###< symfony/framework-bundle ### | ||
|
||
###> symfony/webapp-meta ### | ||
MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=0 | ||
###< symfony/webapp-meta ### | ||
|
||
###> doctrine/doctrine-bundle ### | ||
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url | ||
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml | ||
# | ||
# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db" | ||
# DATABASE_URL="mysql://db_user:[email protected]:3306/db_name?serverVersion=5.7&charset=utf8mb4" | ||
DATABASE_URL="postgresql://symfony:[email protected]:5432/app?serverVersion=13&charset=utf8" | ||
###< doctrine/doctrine-bundle ### | ||
|
||
###> symfony/messenger ### | ||
# Choose one of the transports below | ||
# MESSENGER_TRANSPORT_DSN=doctrine://default | ||
# MESSENGER_TRANSPORT_DSN=amqp://guest:guest@localhost:5672/%2f/messages | ||
# MESSENGER_TRANSPORT_DSN=redis://localhost:6379/messages | ||
###< symfony/messenger ### | ||
|
||
###> symfony/mailer ### | ||
# MAILER_DSN=null://null | ||
###< symfony/mailer ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# define your env variables for the test env here | ||
KERNEL_CLASS='App\Kernel' | ||
APP_SECRET='$ecretf0rt3st' | ||
SYMFONY_DEPRECATIONS_HELPER=999999 | ||
PANTHER_APP_ENV=panther | ||
PANTHER_ERROR_SCREENSHOT_DIR=./var/error-screenshots |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
env: | ||
browser: true | ||
es6: true | ||
node: true | ||
extends: | ||
- 'eslint:recommended' | ||
globals: | ||
Atomics: readonly | ||
SharedArrayBuffer: readonly | ||
parserOptions: | ||
ecmaVersion: 2021 | ||
sourceType: module | ||
ecmaFeatures: | ||
jsx: true | ||
rules: { | ||
no-console: 'error', | ||
indent: ['error', 4], | ||
no-unused-vars: 0, | ||
no-param-reassign: 0, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: deploy | ||
on: | ||
push: | ||
branches: [ main ] | ||
|
||
jobs: | ||
# This workflow contains a single job called "build" | ||
build: | ||
# The type of runner that the job will run on | ||
runs-on: ubuntu-latest | ||
|
||
# Steps represent a sequence of tasks that will be executed as part of the job | ||
steps: | ||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: '19' | ||
|
||
- name: Install caprover | ||
run: npm install -g caprover | ||
|
||
- name: Caprover Deploy | ||
run: caprover deploy -h '${{ secrets.CAPROVER_SERVER }}' -p '${{ secrets.CAPROVER_PASSWORD }}' -b 'main' -a '${{ secrets.CAPROVER_APP_NAME }}' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# This is a basic workflow to help you get started with Actions | ||
|
||
name: CI | ||
|
||
# Controls when the action will run. Triggers the workflow on push or pull request | ||
# events but only for the master branch | ||
on: | ||
push: | ||
branches: [ dev, main ] | ||
pull_request: | ||
branches: [ dev, main ] | ||
|
||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | ||
jobs: | ||
# This workflow contains a single job called "build" | ||
build: | ||
# The type of runner that the job will run on | ||
runs-on: ubuntu-latest | ||
|
||
# Steps represent a sequence of tasks that will be executed as part of the job | ||
steps: | ||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | ||
- uses: actions/checkout@v2 | ||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: 8.1 | ||
|
||
- name: checks_directory | ||
run: | | ||
if [ -d "./.idea" ]; then echo "Forbidden PHPStorm folder (.idea/) found ! Please, ignore in .gitignore"; exit 2; fi | ||
if [ -d "./.vscode" ]; then echo "Forbidden VScode folder (.vscode) found ! Please, ignore in .gitignore"; exit 2; fi | ||
if [ $(find ./ -name .DS_Store) ]; then echo "Forbidden MacOS boring file (.DS_Store) found ! Please, ignore in .gitignore"; exit 2; fi | ||
if [ -d "./vendor" ]; then echo "Forbidden external libs folder (vendor/) found !"; exit 2; fi | ||
- name: Composer | ||
run: composer install | ||
|
||
- name: Yarn | ||
run: yarn --ignore-engines install | ||
|
||
- name: code_quality | ||
run: | | ||
./vendor/bin/phpcs | ||
./vendor/bin/phpstan analyse src --level 6 | ||
./vendor/bin/phpmd src text phpmd.xml | ||
./node_modules/.bin/eslint assets | ||
- name: phpunit | ||
run: bin/phpunit | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
.idea/ | ||
.vscode/ | ||
.DS_Store | ||
db-data | ||
###> symfony/framework-bundle ### | ||
/.env.local | ||
/.env.local.php | ||
/.env.*.local | ||
/config/secrets/prod/prod.decrypt.private.php | ||
/public/bundles/ | ||
/var/ | ||
/vendor/ | ||
###< symfony/framework-bundle ### | ||
|
||
###> symfony/webpack-encore-bundle ### | ||
/node_modules/ | ||
/public/build/ | ||
npm-debug.log | ||
yarn-error.log | ||
###< symfony/webpack-encore-bundle ### | ||
|
||
###> squizlabs/php_codesniffer ### | ||
/.phpcs-cache | ||
/phpcs.xml | ||
###< squizlabs/php_codesniffer ### | ||
|
||
###> symfony/phpunit-bridge ### | ||
.phpunit.result.cache | ||
/phpunit.xml | ||
###< symfony/phpunit-bridge ### | ||
|
||
###> phpunit/phpunit ### | ||
/phpunit.xml | ||
.phpunit.result.cache | ||
###< phpunit/phpunit ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# | ||
# Prep App's PHP Dependencies | ||
# | ||
FROM composer:2.1 as vendor | ||
|
||
WORKDIR /app | ||
|
||
COPY composer.json composer.json | ||
COPY composer.lock composer.lock | ||
|
||
RUN composer install \ | ||
--ignore-platform-reqs \ | ||
--no-interaction \ | ||
--no-plugins \ | ||
--no-scripts \ | ||
--prefer-dist \ | ||
--quiet | ||
|
||
FROM php:8.1-fpm-alpine as phpserver | ||
|
||
# add cli tools | ||
RUN apk update \ | ||
&& apk upgrade \ | ||
&& apk add nginx | ||
|
||
RUN apk add --no-cache \ | ||
libzip-dev \ | ||
zip \ | ||
&& docker-php-ext-install zip | ||
|
||
# silently install 'docker-php-ext-install' extensions | ||
RUN set -x | ||
|
||
RUN docker-php-ext-install pdo_mysql bcmath > /dev/null | ||
|
||
|
||
COPY nginx.conf /etc/nginx/nginx.conf | ||
|
||
COPY php.ini /usr/local/etc/php/conf.d/local.ini | ||
RUN cat /usr/local/etc/php/conf.d/local.ini | ||
|
||
WORKDIR /var/www | ||
|
||
COPY . /var/www/ | ||
COPY --from=vendor /app/vendor /var/www/vendor | ||
|
||
# | ||
# Prep App's Frontend CSS & JS now | ||
# so some symfony UX dependencies can access to vendor | ||
# | ||
RUN apk add nodejs | ||
RUN apk add npm | ||
RUN npm install npm@latest -g | ||
RUN npm install yarn@latest -g | ||
RUN node -v | ||
RUN npm -v | ||
RUN yarn install | ||
RUN yarn run build | ||
|
||
EXPOSE 80 | ||
|
||
COPY docker-entry.sh /etc/entrypoint.sh | ||
ENTRYPOINT ["sh", "/etc/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
# Project 3 - Starter Kit - Symfony | ||
|
||
## Presentation | ||
|
||
This starter kit is here to easily start a repository for Wild Code School students. | ||
|
||
It's symfony website-skeleton project with some additional library (webpack, fixtures) and tools to validate code standards. | ||
|
||
* GrumPHP, as pre-commit hook, will run 2 tools when `git commit` is run : | ||
|
||
* PHP_CodeSniffer to check PSR12 | ||
* PHPStan focuses on finding errors in your code (without actually running it) | ||
* PHPmd will check if you follow PHP best practices | ||
|
||
If tests fail, the commit is canceled and a warning message is displayed to developper. | ||
|
||
* Github Action as Continuous Integration will be run when a branch with active pull request is updated on github. It will run : | ||
|
||
* Tasks to check if vendor, .idea, env.local are not versionned, | ||
* PHP_CodeSniffer, PHPStan and PHPmd with same configuration as GrumPHP. | ||
|
||
## Getting Started for Students | ||
|
||
### Prerequisites | ||
|
||
1. Check composer is installed | ||
2. Check yarn & node are installed | ||
|
||
### Install | ||
|
||
1. Clone this project | ||
2. Run `composer install` | ||
3. Run `yarn install` | ||
4. Run `yarn encore dev` to build assets | ||
|
||
### Working | ||
|
||
1. Run `symfony server:start` to launch your local php web server | ||
2. Run `yarn run dev --watch` to launch your local server for assets (or `yarn dev-server` do the same with Hot Module Reload activated) | ||
|
||
### Testing | ||
|
||
1. Run `php ./vendor/bin/phpcs` to launch PHP code sniffer | ||
2. Run `php ./vendor/bin/phpstan analyse src --level max` to launch PHPStan | ||
3. Run `php ./vendor/bin/phpmd src text phpmd.xml` to launch PHP Mess Detector | ||
4. Run `./node_modules/.bin/eslint assets/js` to launch ESLint JS linter | ||
|
||
### Windows Users | ||
|
||
If you develop on Windows, you should edit you git configuration to change your end of line rules with this command: | ||
|
||
`git config --global core.autocrlf true` | ||
|
||
The `.editorconfig` file in root directory do this for you. You probably need `EditorConfig` extension if your IDE is VSCode. | ||
|
||
### Run locally with Docker | ||
|
||
1. Fill DATABASE_URL variable in .env.local file with | ||
`DATABASE_URL="mysql://root:password@database:3306/<choose_a_db_name>"` | ||
2. Install Docker Desktop an run the command: | ||
```bash | ||
docker-compose up -d | ||
``` | ||
3. Wait a moment and visit http://localhost:8000 | ||
|
||
|
||
## Deployment | ||
|
||
Some files are used to manage automatic deployments (using tools as Caprover, Docker and Github Action). Please do not modify them. | ||
|
||
* [captain-definition](/captain-definition) Caprover entry point | ||
* [Dockerfile](/Dockerfile) Web app configuration for Docker container | ||
* [docker-entry.sh](/docker-entry.sh) shell instruction to execute when docker image is built | ||
* [nginx.conf](/ginx.conf) Nginx server configuration | ||
* [php.ini](/php.ini) Php configuration | ||
|
||
|
||
## Built With | ||
|
||
* [Symfony](https://github.com/symfony/symfony) | ||
* [GrumPHP](https://github.com/phpro/grumphp) | ||
* [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) | ||
* [PHPStan](https://github.com/phpstan/phpstan) | ||
* [PHPMD](http://phpmd.org) | ||
* [ESLint](https://eslint.org/) | ||
* [Sass-Lint](https://github.com/sasstools/sass-lint) | ||
|
||
|
||
|
||
## Contributing | ||
|
||
Please read [CONTRIBUTING.md](https://gist.github.com/PurpleBooth/b24679402957c63ec426) for details on our code of conduct, and the process for submitting pull requests to us. | ||
|
||
## Versioning | ||
|
||
|
||
## Authors | ||
|
||
Wild Code School trainers team | ||
|
||
## License | ||
|
||
MIT License | ||
|
||
Copyright (c) 2019 [email protected] | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
|
||
## Acknowledgments | ||
|
Oops, something went wrong.