Skip to content

Commit a87d010

Browse files
committed
project
0 parents  commit a87d010

14 files changed

+336
-0
lines changed

.env.dist

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# This file is a "template" of which env vars needs to be defined in your configuration or in an .env file
2+
# Set variables here that may be different on each deployment target of the app, e.g. development, staging, production.
3+
# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration
4+
5+
###> symfony/framework-bundle ###
6+
APP_ENV=dev
7+
APP_DEBUG=1
8+
APP_SECRET=c2e19906f05378569f0f5357d3245bdd
9+
RABBITMQ_HOST=localhost
10+
RABBITMQ_PORT=5672
11+
RABBITMQ_USER=guest
12+
RABBITMQ_PASS=guest
13+
RABBITMQ_VHOST=/
14+
###< symfony/framework-bundle ###

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
###> symfony/framework-bundle ###
2+
.env
3+
/var/
4+
/vendor/
5+
/web/bundles/
6+
###< symfony/framework-bundle ###

Makefile

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
ifndef APP_ENV
2+
include .env
3+
endif
4+
5+
###> symfony/framework-bundle ###
6+
cache-clear:
7+
@test -f bin/console && bin/console cache:clear --no-warmup || rm -rf var/cache/*
8+
.PHONY: cache-clear
9+
10+
cache-warmup: cache-clear
11+
@test -f bin/console && bin/console cache:warmup || echo "cannot warmup the cache (needs symfony/console)"
12+
.PHONY: cache-warmup
13+
14+
CONSOLE=bin/console
15+
sf_console:
16+
@test -f $(CONSOLE) || printf "Run \033[32mcomposer require cli\033[39m to install the Symfony console.\n"
17+
@exit
18+
19+
serve_as_sf: sf_console
20+
@test -f $(CONSOLE) && $(CONSOLE)|grep server:start > /dev/null || ${MAKE} serve_as_php
21+
@$(CONSOLE) server:start || exit 1
22+
23+
@printf "Quit the server with \033[32;49mbin/console server:stop.\033[39m\n"
24+
25+
serve_as_php:
26+
@printf "\033[32;49mServer listening on http://127.0.0.1:8000\033[39m\n";
27+
@printf "Quit the server with CTRL-C.\n"
28+
@printf "Run \033[32mcomposer require symfony/web-server-bundle\033[39m for a better web server\n"
29+
php -S 127.0.0.1:8000 -t web
30+
31+
serve:
32+
@${MAKE} serve_as_sf
33+
.PHONY: sf_console serve serve_as_sf serve_as_php
34+
###< symfony/framework-bundle ###

bin/console

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
use Quartz\App\Kernel;
5+
use Symfony\Bundle\FrameworkBundle\Console\Application;
6+
use Symfony\Component\Dotenv\Dotenv;
7+
use Symfony\Component\Console\Input\ArgvInput;
8+
use Symfony\Component\Debug\Debug;
9+
10+
umask(0000);
11+
set_time_limit(0);
12+
13+
$dir = realpath(dirname($_SERVER['PHP_SELF']));
14+
$loader = require $dir.'/../vendor/autoload.php';
15+
16+
if (!class_exists(Application::class)) {
17+
throw new \RuntimeException('You need to add "symfony/framework-bundle" as a Composer dependency.');
18+
}
19+
20+
if (!getenv('APP_ENV')) {
21+
(new Dotenv())->load(__DIR__.'/../.env');
22+
}
23+
24+
$input = new ArgvInput();
25+
$env = $input->getParameterOption(['--env', '-e'], getenv('APP_ENV') ?: 'dev');
26+
$debug = getenv('APP_DEBUG') !== '0' && !$input->hasParameterOption(['--no-debug', '']);
27+
28+
if ($debug && class_exists(Debug::class)) {
29+
Debug::enable();
30+
}
31+
32+
$kernel = new Kernel($env, $debug);
33+
$application = new Application($kernel);
34+
$application->run($input);

composer.json

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"name": "formapro/php-quartz-app",
3+
"type": "project",
4+
"license": "MIT",
5+
"description": "Job Time Scheduler App",
6+
"keywords": ["job", "time", "task", "time scheduler", "quartz", "chrono"],
7+
"require": {
8+
"php": "^7.1.3",
9+
"symfony/console": "^3.3",
10+
"symfony/flex": "^1.0",
11+
"symfony/framework-bundle": "^3.3",
12+
"symfony/yaml": "^3.3",
13+
"enqueue/enqueue": "^0.3|^0.4",
14+
"enqueue/amqp-ext": "^0.3|^0.4",
15+
"enqueue/enqueue-bundle": "^0.3|^0.4"
16+
},
17+
"require-dev": {
18+
"symfony/dotenv": "^3.3"
19+
},
20+
"config": {
21+
"preferred-install": {
22+
"*": "dist"
23+
},
24+
"sort-packages": true
25+
},
26+
"autoload": {
27+
"psr-4": {
28+
"Quartz\\App\\": "src/"
29+
}
30+
},
31+
"autoload-dev": {
32+
"psr-4": {
33+
"Quartz\\App\\Tests\\": "tests/"
34+
}
35+
},
36+
"scripts": {
37+
"auto-scripts": {
38+
"make cache-warmup": "script"
39+
},
40+
"post-install-cmd": [
41+
"@auto-scripts"
42+
],
43+
"post-update-cmd": [
44+
"@auto-scripts"
45+
]
46+
},
47+
"conflict": {
48+
"symfony/symfony": "*",
49+
"symfony/twig-bundle": "<3.3",
50+
"symfony/debug": "<3.3"
51+
},
52+
"extra": {
53+
"symfony": {
54+
"id": "01BJQZD7YBT9JB0NGH2G58754G",
55+
"allow-contrib": false
56+
}
57+
}
58+
}

docker-compose.yml

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
version: '3'
2+
services:
3+
scheduler:
4+
image: 'formapro/nginx-php-fpm:latest-all-exts'
5+
working_dir: '/app/App'
6+
entrypoint: 'php bin/quartz.php scheduler --setup -vvv'
7+
restart: 'on-failure'
8+
depends_on:
9+
- 'mongo'
10+
- 'rabbitmq'
11+
volumes:
12+
- './:/app:cached'
13+
# - './docker/xdebug.ini:/etc/php/7.0/mods-available/xdebug.ini'
14+
environment:
15+
PHP_IDE_CONFIG: 'serverName=quartz.dev'
16+
XDEBUG_CONFIG: 'idekey=PHPSTORM'
17+
MONGODB_HOST: 'mongo'
18+
MONGODB_PORT: '27017'
19+
MONGODB_DB: 'quartz'
20+
RABBITMQ_HOST: 'rabbitmq'
21+
RABBITMQ_PORT: '5672'
22+
RABBITMQ_USER: 'guest'
23+
RABBITMQ_PASS: 'guest'
24+
RABBITMQ_VHOST: 'quartz'
25+
26+
worker:
27+
image: 'formapro/nginx-php-fpm:latest-all-exts'
28+
working_dir: '/app/App'
29+
entrypoint: 'php bin/quartz.php worker -vvv'
30+
restart: 'on-failure'
31+
depends_on:
32+
- 'mongo'
33+
- 'rabbitmq'
34+
volumes:
35+
- './:/app:cached'
36+
# - './docker/xdebug.ini:/etc/php/7.0/mods-available/xdebug.ini'
37+
environment:
38+
PHP_IDE_CONFIG: 'serverName=quartz.dev'
39+
XDEBUG_CONFIG: 'idekey=PHPSTORM'
40+
MONGODB_HOST: 'mongo'
41+
MONGODB_PORT: '27017'
42+
MONGODB_DB: 'quartz'
43+
RABBITMQ_HOST: 'rabbitmq'
44+
RABBITMQ_PORT: '5672'
45+
RABBITMQ_USER: 'guest'
46+
RABBITMQ_PASS: 'guest'
47+
RABBITMQ_VHOST: 'quartz'
48+
49+
mongo:
50+
image: 'mongo:3'
51+
restart: 'no'
52+
ports:
53+
- '27017:27017'
54+
55+
rabbitmq:
56+
image: 'enqueue/rabbitmq:latest'
57+
restart: 'no'
58+
ports:
59+
- "15672:15672"
60+
environment:
61+
RABBITMQ_DEFAULT_USER: 'guest'
62+
RABBITMQ_DEFAULT_PASS: 'guest'
63+
RABBITMQ_DEFAULT_VHOST: 'quartz'

etc/bundles.php

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
3+
return [
4+
'Symfony\Bundle\FrameworkBundle\FrameworkBundle' => ['all' => true],
5+
'Enqueue\Bundle\EnqueueBundle' => ['all' => true],
6+
];

etc/container.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Put parameters here that don't need to change on each machine where the app is deployed
2+
# https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
3+
parameters:
4+
5+
services:
6+
quartz.event_dispatcher:
7+
alias: 'event_dispatcher'

etc/packages/app.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
services:
2+
# default configuration for services in *this* file
3+
_defaults:
4+
# automatically injects dependencies in your services
5+
autowire: true
6+
# automatically registers your services as commands, event subscribers, etc.
7+
autoconfigure: true
8+
# this means you cannot fetch services directly from the container via $container->get()
9+
# if you need to do this, you can override this setting on individual services
10+
public: false
11+
12+
# makes classes in src/ available to be used as services
13+
# this creates a service per class whose id is the fully-qualified class name
14+
Quartz\App\:
15+
resource: '../../src/*'
16+
# you can exclude directories or files
17+
# but if a service is unused, it's removed anyway
18+
exclude: '../../src/{Entity,Repository,Tests}'

etc/packages/enqueue.yaml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
enqueue:
2+
transport:
3+
default: 'rabbitmq_amqp'
4+
rabbitmq_amqp:
5+
host: '%env(RABBITMQ_HOST)%'
6+
port: '%env(RABBITMQ_PORT)%'
7+
user: '%env(RABBITMQ_USER)%'
8+
pass: '%env(RABBITMQ_PASS)%'
9+
vhost: '%env(RABBITMQ_VHOST)%'
10+
client:
11+
app: 'quartz'

etc/packages/framework.yaml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
framework:
2+
secret: '%env(APP_SECRET)%'
3+
#default_locale: en
4+
#csrf_protection: null
5+
#http_method_override: true
6+
#trusted_hosts: null
7+
# https://symfony.com/doc/current/reference/configuration/framework.html#handler-id
8+
#session:
9+
# handler_id: session.handler.native_file
10+
# save_path: '%kernel.project_dir%/var/sessions/%kernel.environment%'
11+
#esi: ~
12+
#fragments: ~
13+
php_errors:
14+
log: true

etc/packages/quartz.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
quartz: ~

etc/packages/test/framework.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
framework:
2+
test: null
3+
session:
4+
storage_id: session.storage.mock_file

src/Kernel.php

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
3+
namespace Quartz\App;
4+
5+
use Quartz\Bridge\DI\QuartzExtension;
6+
use Quartz\Bridge\DI\QuartzJobCompilerPass;
7+
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
8+
use Symfony\Component\Config\Loader\LoaderInterface;
9+
use Symfony\Component\DependencyInjection\ContainerBuilder;
10+
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
11+
use Symfony\Component\Routing\RouteCollectionBuilder;
12+
13+
/**
14+
* @author Fabien Potencier <[email protected]>
15+
*/
16+
final class Kernel extends BaseKernel
17+
{
18+
use MicroKernelTrait;
19+
20+
private const CONFIG_EXTS = '.{php,xml,yaml,yml}';
21+
22+
public function getCacheDir(): string
23+
{
24+
return dirname(__DIR__).'/var/cache/'.$this->environment;
25+
}
26+
27+
public function getLogDir(): string
28+
{
29+
return dirname(__DIR__).'/var/logs';
30+
}
31+
32+
public function registerBundles(): iterable
33+
{
34+
$contents = require dirname(__DIR__).'/etc/bundles.php';
35+
foreach ($contents as $class => $envs) {
36+
if (isset($envs['all']) || isset($envs[$this->environment])) {
37+
yield new $class();
38+
}
39+
}
40+
}
41+
42+
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
43+
{
44+
$container->registerExtension(new QuartzExtension());
45+
$container->addCompilerPass(new QuartzJobCompilerPass());
46+
47+
$confDir = dirname(__DIR__).'/etc';
48+
$loader->load($confDir.'/packages/*'.self::CONFIG_EXTS, 'glob');
49+
if (is_dir($confDir.'/packages/'.$this->environment)) {
50+
$loader->load($confDir.'/packages/'.$this->environment.'/**/*'.self::CONFIG_EXTS, 'glob');
51+
}
52+
$loader->load($confDir.'/container'.self::CONFIG_EXTS, 'glob');
53+
}
54+
55+
protected function configureRoutes(RouteCollectionBuilder $routes): void
56+
{
57+
$confDir = dirname(__DIR__).'/etc';
58+
if (is_dir($confDir.'/routing/')) {
59+
$routes->import($confDir.'/routing/*'.self::CONFIG_EXTS, '/', 'glob');
60+
}
61+
if (is_dir($confDir.'/routing/'.$this->environment)) {
62+
$routes->import($confDir.'/routing/'.$this->environment.'/**/*'.self::CONFIG_EXTS, '/', 'glob');
63+
}
64+
$routes->import($confDir.'/routing'.self::CONFIG_EXTS, '/', 'glob');
65+
}
66+
}

0 commit comments

Comments
 (0)