-
Notifications
You must be signed in to change notification settings - Fork 15
[php] Add symfony framework #7193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
e49e8b5
d745be4
10b0c4b
9eccf28
5300a92
1f910f2
b178c47
656aa22
633c8b5
35ec697
13952ee
53427f9
a56ba32
d628573
27cdcbf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| ARG PHP_VERSION=8.2 | ||
| ARG VARIANT=release | ||
|
|
||
| FROM datadog/dd-appsec-php-ci:php-$PHP_VERSION-$VARIANT | ||
|
|
||
| ENV PHP_VERSION=8.2 | ||
| ENV DD_TRACE_ENABLED=1 | ||
| ENV DD_TRACE_GENERATE_ROOT_SPAN=1 | ||
| ENV DD_TRACE_AGENT_FLUSH_AFTER_N_REQUESTS=0 | ||
| ENV DD_TRACE_HEADER_TAGS=user-agent | ||
|
|
||
| EXPOSE 7777/tcp | ||
|
|
||
| ADD binaries* /binaries/ | ||
| ADD utils/build/docker/php /tmp/php | ||
|
|
||
| # Pre-create .env with APP_SECRET and APP_ENV | ||
| RUN mkdir -p /var/www/html && \ | ||
| echo "APP_ENV=prod" > /var/www/html/.env && \ | ||
| php -r "echo 'APP_SECRET=' . bin2hex(random_bytes(16)) . PHP_EOL;" >> /var/www/html/.env && \ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This only writes Useful? React with 👍 / 👎. |
||
| echo "APP_DEBUG=0" >> /var/www/html/.env && \ | ||
| echo "SYMFONY_DB_PATH=/tmp/symfony.db" >> /var/www/html/.env | ||
|
|
||
| RUN chmod +x /tmp/php/apache-mod/build.sh | ||
| RUN /tmp/php/apache-mod/build.sh symfony7x | ||
|
|
||
| # Use Symfony-specific Apache config (DocumentRoot public/, AllowOverride All) | ||
| RUN cp /tmp/php/weblogs/symfony7x/.apache.conf /etc/apache2/mods-available/php.conf && \ | ||
| sed -i "s/%PHP_MAJOR_VERSION//g" /etc/apache2/mods-available/php.conf && \ | ||
| ln -sf /etc/apache2/mods-available/php.conf /etc/apache2/mods-enabled/php.conf | ||
|
|
||
| # pdo_sqlite, dom, and tokenizer are needed by Symfony (mirrors laravel11x pattern; tokenizer for attribute routing) | ||
| RUN printf "extension=dom.so\nextension=pdo_sqlite.so\nextension=tokenizer.so\n" >> /etc/php/php.ini | ||
|
|
||
| # Create log directory before running PHP (php.ini writes error_log there) | ||
| RUN mkdir -p /var/log/system-tests | ||
|
|
||
| # Create SQLite database and seed test users (script is at /var/www/html/bin/init-db.php via build.sh) | ||
| RUN SYMFONY_DB_PATH=/tmp/symfony.db php /var/www/html/bin/init-db.php && \ | ||
| chmod 666 /tmp/symfony.db | ||
|
|
||
| # Warm up Symfony cache | ||
| RUN cd /var/www/html && APP_ENV=prod php bin/console cache:warmup | ||
|
|
||
| # Install ddtrace (same pattern as apache-mod-X.Y.Dockerfiles) | ||
| ADD utils/build/docker/php/common/install_ddtrace.sh /install_ddtrace.sh | ||
| RUN /install_ddtrace.sh 1 | ||
|
|
||
| # Set writable permissions on var/ directory | ||
| RUN chmod -R 775 /var/www/html/var && \ | ||
| chown -R www-data:www-data /var/www/html/var | ||
|
|
||
| RUN rm -rf /tmp/php/ | ||
|
|
||
| ADD utils/build/docker/php/apache-mod/entrypoint.sh / | ||
| WORKDIR /binaries | ||
| ENTRYPOINT [] | ||
| RUN echo "#!/bin/bash\ndumb-init /entrypoint.sh" > app.sh | ||
| RUN chmod +x app.sh | ||
| CMD [ "./app.sh" ] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| <IfModule mod_php%PHP_MAJOR_VERSION.c> | ||
| <VirtualHost *:7777> | ||
| DocumentRoot /var/www/html/public | ||
| AllowEncodedSlashes NoDecode | ||
| <Directory /var/www/html/public> | ||
| AllowOverride All | ||
| Require all granted | ||
| </Directory> | ||
| </VirtualHost> | ||
| <FilesMatch "\.php$"> | ||
| SetHandler application/x-httpd-php | ||
| Require all granted | ||
| </FilesMatch> | ||
| PHPIniDir "/etc/php/php.ini" | ||
| </IfModule> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| { | ||
| "name": "weblog/acme", | ||
| "description": "Just a package to test the composer libraries are sent", | ||
| "type": "library", | ||
| "require": {}, | ||
| "version": "1.0.0", | ||
| "autoload": { | ||
| "psr-4": { | ||
| "Acme\\": "src/" | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| <?php | ||
|
|
||
| namespace Acme; | ||
|
|
||
| class Acme { | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| #!/usr/bin/env php | ||
| <?php | ||
|
|
||
| use App\Kernel; | ||
| use Symfony\Bundle\FrameworkBundle\Console\Application; | ||
| use Symfony\Component\Console\Input\ArgvInput; | ||
|
|
||
| require dirname(__DIR__).'/vendor/autoload.php'; | ||
|
|
||
| $input = new ArgvInput(); | ||
| $env = $input->getParameterOption(['--env', '-e'], $_SERVER['APP_ENV'] ?? 'prod', true); | ||
| $debug = (bool) ($_SERVER['APP_DEBUG'] ?? ('prod' !== $env)) && !$input->hasParameterOption('--no-debug', true); | ||
|
|
||
| $kernel = new Kernel($env, $debug); | ||
| $app = new Application($kernel); | ||
| $app->run($input); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| #!/usr/bin/env php | ||
| <?php | ||
|
|
||
| use App\Entity\User; | ||
| use Doctrine\DBAL\DriverManager; | ||
| use Doctrine\ORM\EntityManager; | ||
| use Doctrine\ORM\ORMSetup; | ||
| use Doctrine\ORM\Tools\SchemaTool; | ||
|
|
||
| require dirname(__DIR__) . '/vendor/autoload.php'; | ||
|
|
||
| $dbPath = getenv('SYMFONY_DB_PATH') ?: '/tmp/symfony.db'; | ||
|
|
||
| $config = ORMSetup::createAttributeMetadataConfiguration( | ||
| paths: [dirname(__DIR__) . '/src/Entity'], | ||
| isDevMode: false, | ||
| ); | ||
|
|
||
| $connection = DriverManager::getConnection(['driver' => 'pdo_sqlite', 'path' => $dbPath]); | ||
| $em = new EntityManager($connection, $config); | ||
|
|
||
| (new SchemaTool($em))->createSchema($em->getMetadataFactory()->getAllMetadata()); | ||
|
|
||
| $seeds = [ | ||
| ['id' => 'social-security-id', 'username' => 'test', 'password' => '1234'], | ||
| ['id' => '591dc126-8431-4d0f-9509-b23318d3dce4', 'username' => 'testuuid', 'password' => '1234'], | ||
| ]; | ||
|
|
||
| foreach ($seeds as $seed) { | ||
| if ($em->find(User::class, $seed['id']) === null) { | ||
| $em->persist(new User($seed['id'], $seed['username'], password_hash($seed['password'], PASSWORD_BCRYPT), $seed['username'])); | ||
| } | ||
| } | ||
|
|
||
| $em->flush(); | ||
|
|
||
| echo "Database initialized at $dbPath\n"; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| { | ||
| "name": "php/symfony-weblog", | ||
| "type": "project", | ||
| "require": { | ||
| "php": ">=8.2", | ||
| "ext-ctype": "*", | ||
| "ext-iconv": "*", | ||
| "doctrine/doctrine-bundle": "^2.13", | ||
| "doctrine/orm": "^3.3", | ||
| "stripe/stripe-php": "^10.0", | ||
| "symfony/console": "^7.2", | ||
| "symfony/framework-bundle": "^7.2", | ||
| "symfony/security-bundle": "^7.2", | ||
| "symfony/dom-crawler": "^7.2", | ||
| "symfony/filesystem": "^7.2", | ||
| "symfony/http-client": "^7.2", | ||
| "symfony/process": "^7.2", | ||
| "symfony/yaml": "^7.2", | ||
| "monolog/monolog": "^3.0", | ||
| "weblog/acme": "*" | ||
| }, | ||
| "repositories": [ | ||
| { | ||
| "type": "path", | ||
| "url": "./Acme", | ||
| "options": { | ||
| "symlink": true | ||
| } | ||
| } | ||
| ], | ||
| "autoload": { | ||
| "psr-4": { | ||
| "App\\": "src/" | ||
| } | ||
| }, | ||
| "config": { | ||
| "optimize-autoloader": true, | ||
| "preferred-install": "dist", | ||
| "sort-packages": true, | ||
| "allow-plugins": { | ||
| "symfony/flex": false | ||
| }, | ||
| "platform": { | ||
| "ext-ctype": "8.2.0", | ||
| "ext-iconv": "8.2.0", | ||
| "ext-curl": "8.2.0", | ||
| "ext-json": "8.2.0", | ||
| "ext-mbstring": "8.2.0", | ||
| "ext-openssl": "8.2.0", | ||
| "ext-pdo": "8.2.0", | ||
| "ext-session": "8.2.0", | ||
| "ext-tokenizer": "8.2.0", | ||
| "ext-dom": "8.2.0", | ||
| "ext-xml": "8.2.0" | ||
| } | ||
| }, | ||
| "minimum-stability": "stable", | ||
| "prefer-stable": true | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| <?php | ||
|
|
||
| return [ | ||
| Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true], | ||
| Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true], | ||
| Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true], | ||
| ]; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| parameters: | ||
| default_sqlite_path: '/tmp/symfony.db' | ||
|
|
||
| doctrine: | ||
| dbal: | ||
| default_connection: default | ||
| connections: | ||
| default: | ||
| driver: pdo_sqlite | ||
| path: '%env(default:default_sqlite_path:SYMFONY_DB_PATH)%' | ||
| server_version: '3.39' | ||
| mysql: | ||
| driver: pdo_mysql | ||
| host: mysqldb | ||
| dbname: mysql_dbname | ||
| user: mysqldb | ||
| password: mysqldb | ||
| server_version: '8.0' | ||
| postgres: | ||
| driver: pdo_pgsql | ||
| host: postgres | ||
| port: 5433 | ||
| dbname: system_tests_dbname | ||
| user: system_tests_user | ||
| password: system_tests | ||
| server_version: '14.0' | ||
| orm: | ||
| auto_generate_proxy_classes: true | ||
| naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware | ||
| mappings: | ||
| App: | ||
| is_bundle: false | ||
| type: attribute | ||
| dir: '%kernel.project_dir%/src/Entity' | ||
| prefix: 'App\Entity' | ||
| alias: App |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For
WEBLOG_VARIANT=symfony7x, the new helper returns false, sotest_login_event_blocking_auto_idonly checks the initial login and remote-config ACKs and never validates thatself.r_login_blockedproduced theblock-user-idattack or a 403. That turns an enabled test into a no-op for this weblog; mark the Symfony case in the manifest or split the expectation instead of gating the core assertions at runtime.Useful? React with 👍 / 👎.