Skip to content
This repository has been archived by the owner on Nov 30, 2023. It is now read-only.

Commit

Permalink
Create one directory for api to separate api files and admin files
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume KESTEMAN committed Jul 12, 2022
1 parent 819d6a0 commit d5868b8
Show file tree
Hide file tree
Showing 136 changed files with 116 additions and 94 deletions.
45 changes: 9 additions & 36 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,44 +1,17 @@
/.env
/helm/api-platform/charts/*
!/helm/api-platform/charts/.gitignore
/docker-compose.override.yml
!/docker-compose.override.yml.dist

###> phpstorm ###
/.idea
###< phpstorm ###

###> symfony/framework-bundle ###
/.env.local
/.env.local.php
/.env.*.local
/config/secrets/prod/prod.decrypt.private.php
/public/bundles/
/var/
/vendor/
###< symfony/framework-bundle ###

###> phpunit/phpunit ###
/phpunit.xml
.phpunit.result.cache
###< phpunit/phpunit ###

###> symfony/phpunit-bridge ###
.phpunit.result.cache
/phpunit.xml
###< symfony/phpunit-bridge ###

###> symfony/webpack-encore-bundle ###
/node_modules/
/public/build/
npm-debug.log
yarn-error.log
###< symfony/webpack-encore-bundle ###

###> phpstorm ###
/.idea
###< phpstorm ###

###> lexik/jwt-authentication-bundle ###
/config/jwt/*.pem
###< lexik/jwt-authentication-bundle ###

###> public/media ###
/public/media/
###< public/media ###

###> controller/testcontroller ###
/src/Controller/TestController.php
/templates/test
###< controller/testcontroller ###
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ start-all:
docker-compose exec php bin/console doctrine:migrations:migrate --no-interaction
docker-compose exec php bin/console doctrine:fixtures:load --no-interaction
sleep 5
cd my-admin/ && yarn start
cd admin/ && yarn start

stop-all:
docker-compose down

install:
mkdir -p public/media
mkdir -p api/public/media
sudo chown -R $(user):docker .
chmod -R g+w .
docker-compose build --pull --no-cache
cd my-admin/ && yarn install
cd admin/ && yarn install

kill-docker-builds:
docker-compose stop && docker-compose kill && docker-compose down --volumes --remove-orphans
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

or
- Build docker with `docker-compose build --pull --no-cache`
- Go to the directory `my-admin/` and install the admin panel dependencies with `yarn install`
- Go to the directory `admin/` and install the admin panel dependencies with `yarn install`
#### Generate JWT keypair :
- Generate JWT keypair with this command : `php bin/console lexik:jwt:generate-keypair`

Expand All @@ -18,7 +18,7 @@
or
- Open a terminal in the root and launch this command : `docker-compose up -d`
- Initialize the database with : `docker-compose exec php bin/console doctrine:fixtures:load`
- And go to the `my-admin/` directory and launch this command : `yarn start`
- And go to the `admin/` directory and launch this command : `yarn start`

### Project Stop :
- Terminate the command `make`/`make start`/`yarn start`
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions my-admin/package-lock.json → admin/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion my-admin/package.json → admin/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "my-admin",
"name": "admin",
"version": "0.1.0",
"private": true,
"dependencies": {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
44 changes: 44 additions & 0 deletions api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

###> symfony/framework-bundle ###
/.env.local
/.env.local.php
/.env.*.local
/config/secrets/prod/prod.decrypt.private.php
/public/bundles/
/var/
/vendor/
###< symfony/framework-bundle ###

###> phpunit/phpunit ###
/phpunit.xml
.phpunit.result.cache
###< phpunit/phpunit ###

###> symfony/phpunit-bridge ###
.phpunit.result.cache
/phpunit.xml
###< symfony/phpunit-bridge ###

###> symfony/webpack-encore-bundle ###
/node_modules/
/public/build/
npm-debug.log
yarn-error.log
###< symfony/webpack-encore-bundle ###

###> phpstorm ###
/.idea
###< phpstorm ###

###> lexik/jwt-authentication-bundle ###
/config/jwt/*.pem
###< lexik/jwt-authentication-bundle ###

###> public/media ###
/public/media/
###< public/media ###

###> controller/testcontroller ###
/src/Controller/TestController.php
/templates/test
###< controller/testcontroller ###
9 changes: 5 additions & 4 deletions Dockerfile → api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ ENV COMPOSER_ALLOW_SUPERUSER=1

ENV PATH="${PATH}:/root/.composer/vendor/bin"

WORKDIR /srv/app
WORKDIR /srv/api

# Allow to choose skeleton
ARG SKELETON="symfony/skeleton"
Expand Down Expand Up @@ -111,7 +111,8 @@ RUN set -eux; \
composer symfony:dump-env prod; \
composer run-script --no-dev post-install-cmd; \
chmod +x bin/console; sync
VOLUME /srv/app/var
VOLUME /srv/api/var
VOLUME /srv/api/config/jwt

ENTRYPOINT ["docker-entrypoint"]
CMD ["php-fpm"]
Expand All @@ -126,9 +127,9 @@ RUN xcaddy build \

FROM caddy:${CADDY_VERSION} AS symfony_caddy

WORKDIR /srv/app
WORKDIR /srv/api

COPY --from=dunglas/mercure:v0.11 /srv/public /srv/mercure-assets/
COPY --from=symfony_caddy_builder /usr/bin/caddy /usr/bin/caddy
COPY --from=symfony_php /srv/app/public public/
COPY --from=symfony_php /srv/api/public public/
COPY docker/caddy/Caddyfile /etc/caddy/Caddyfile
4 changes: 2 additions & 2 deletions bin/console → api/bin/console
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
use App\Kernel;
use Symfony\Bundle\FrameworkBundle\Console\Application;

if (!is_file(dirname(__DIR__).'/vendor/autoload_runtime.php')) {
if (!is_file(dirname(__DIR__) . '/vendor/autoload_runtime.php')) {
throw new LogicException('Symfony Runtime is missing. Try running "composer require symfony/runtime".');
}

require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
require_once dirname(__DIR__) . '/vendor/autoload_runtime.php';

return function (array $context) {
$kernel = new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
Expand Down
19 changes: 19 additions & 0 deletions api/bin/phpunit
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env php
<?php

if (!ini_get('date.timezone')) {
ini_set('date.timezone', 'UTC');
}

if (is_file(dirname(__DIR__) . '/vendor/phpunit/phpunit/phpunit')) {
define('PHPUNIT_COMPOSER_INSTALL', dirname(__DIR__) . '/vendor/autoload.php');
require PHPUNIT_COMPOSER_INSTALL;
PHPUnit\TextUI\Command::main();
} else {
if (!is_file(dirname(__DIR__) . '/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php')) {
echo "Unable to find the `simple-phpunit.php` script in `vendor/symfony/phpunit-bridge/bin/`.\n";
exit(1);
}

require dirname(__DIR__) . '/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php';
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion docker/caddy/Caddyfile → api/docker/caddy/Caddyfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
log

route {
root * /srv/app/public
root * /srv/api/public
mercure {
# Transport to use (default to Bolt)
transport_url {$MERCURE_TRANSPORT_URL:bolt:///data/mercure.db}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ opcache.validate_timestamps = 0
realpath_cache_size = 4096K
realpath_cache_ttl = 600
opcache.preload_user = www-data
opcache.preload = /srv/app/config/preload.php
opcache.preload = /srv/api/config/preload.php
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
2 changes: 1 addition & 1 deletion docs/makefile.md → api/docs/makefile.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ you will probably want to add some targets like running your tests as described
in [the Symfony book](https://symfony.com/doc/current/the-fast-track/en/17-tests.html#automating-your-workflow-with-a-makefile).
You can also find a more complete example in this [snippet](https://www.strangebuzz.com/en/snippets/the-perfect-makefile-for-symfony).

If you want to run make from within the `php` container, in the [Dockerfile](/Dockerfile),
If you want to run make from within the `php` container, in the [Dockerfile](/api/Dockerfile),
add:

```diff
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion docs/xdebug.md → api/docs/xdebug.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Otherwise, you can create a [PHP Remote Debug](https://www.jetbrains.com/help/ph
* Host: `https://localhost` (or the one defined with `SERVER_NAME`)
* Port: `443`
* Debugger: `Xdebug`
* Absolute path on the server: `/srv/app`
* Absolute path on the server: `/srv/api`
* IDE key: `PHPSTORM`

You can now use the debugger.
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion phpunit.xml.dist → api/phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<!-- https://phpunit.readthedocs.io/en/latest/configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
xsi:noNamespaceSchemaLocation="../vendor/phpunit/phpunit/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="tests/bootstrap.php"
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion public/index.php → api/public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use App\Kernel;

require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
require_once dirname(__DIR__) . '/vendor/autoload_runtime.php';

return function (array $context) {
return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'base.html.twig' %}
{% extends '../base.html.twig' %}

{% block title %}Hello CreateMediaObjectActionController!{% endblock %}

Expand Down
11 changes: 11 additions & 0 deletions api/tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

use Symfony\Component\Dotenv\Dotenv;

require dirname(__DIR__) . '/vendor/autoload.php';

if (file_exists(dirname(__DIR__) . '/config/bootstrap.php')) {
require dirname(__DIR__) . '/config/bootstrap.php';
} elseif (method_exists(Dotenv::class, 'bootEnv')) {
(new Dotenv())->bootEnv(dirname(__DIR__) . '/.env');
}
File renamed without changes.
File renamed without changes.
19 changes: 0 additions & 19 deletions bin/phpunit

This file was deleted.

10 changes: 5 additions & 5 deletions docker-compose.override.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ services:
php:
volumes:
# The "cached" option has no effect on Linux but improves performance on Mac
- ./:/srv/app:rw,cached
- ./docker/php/conf.d/symfony.dev.ini:/usr/local/etc/php/conf.d/symfony.ini
- ./api:/srv/api:rw,cached
- ./api/docker/php/conf.d/symfony.dev.ini:/usr/local/etc/php/conf.d/symfony.ini
# If you develop on Mac you can remove the var/ directory from the bind-mount
# for better performance by enabling the next line
# - /srv/app/var
# - /srv/api/var
environment:
APP_ENV: dev

caddy:
volumes:
- ./docker/caddy/Caddyfile:/etc/caddy/Caddyfile:ro
- ./public:/srv/app/public:ro
- ./api/docker/caddy/Caddyfile:/etc/caddy/Caddyfile:ro
- ./api/public:/srv/api/public:ro

###> symfony/mercure-bundle ###
###< symfony/mercure-bundle ###
Expand Down
8 changes: 6 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: "3.4"
services:
php:
build:
context: .
context: ./api
target: symfony_php
args:
SYMFONY_VERSION: ${SYMFONY_VERSION:-}
Expand All @@ -12,6 +12,8 @@ services:
restart: unless-stopped
volumes:
- php_socket:/var/run/php
- ./api:/srv/api:rw,cached
- ./api/var:/srv/api/var:rw
healthcheck:
interval: 10s
timeout: 3s
Expand All @@ -28,7 +30,7 @@ services:

caddy:
build:
context: .
context: api/
target: symfony_caddy
depends_on:
- php
Expand All @@ -41,6 +43,8 @@ services:
- php_socket:/var/run/php
- caddy_data:/data
- caddy_config:/config
- ./api/docker/caddy/Caddyfile:/etc/caddy/Caddyfile:ro
- ./api/public:/srv/api/public:ro
ports:
# HTTP
- target: 80
Expand Down
11 changes: 0 additions & 11 deletions tests/bootstrap.php

This file was deleted.

0 comments on commit d5868b8

Please sign in to comment.