From a6a77968937ade8ec61512d7e5ba64c875fa5202 Mon Sep 17 00:00:00 2001 From: Joseph Bielawski Date: Wed, 11 Oct 2023 15:05:51 +0200 Subject: [PATCH] Add way to run all examples --- composer.json | 1 + composer.lock | 66 ++++++++++++++++++++++++++++++++++++++- examples/bootstrap.php | 12 ++++--- examples/run_examples.php | 39 +++++++++++++++++++++++ 4 files changed, 112 insertions(+), 6 deletions(-) create mode 100755 examples/run_examples.php diff --git a/composer.json b/composer.json index 6afc5d6a5..d118326ae 100644 --- a/composer.json +++ b/composer.json @@ -49,6 +49,7 @@ "ramsey/uuid": "^4.5", "symfony/cache": "^6.2", "symfony/dotenv": "^6.2", + "symfony/finder": "^6.3", "symfony/uid": "^6.3" }, "autoload": { diff --git a/composer.lock b/composer.lock index 1ddfaf484..0f3a24573 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "4af5e1bc3dd5f51f026ef03f08e2d7f7", + "content-hash": "6de5d25741b658ad50f4794e782cdab8", "packages": [ { "name": "amphp/amp", @@ -6443,6 +6443,70 @@ ], "time": "2023-04-21T14:41:17+00:00" }, + { + "name": "symfony/finder", + "version": "v6.3.5", + "source": { + "type": "git", + "url": "https://github.com/symfony/finder.git", + "reference": "a1b31d88c0e998168ca7792f222cbecee47428c4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/finder/zipball/a1b31d88c0e998168ca7792f222cbecee47428c4", + "reference": "a1b31d88c0e998168ca7792f222cbecee47428c4", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "symfony/filesystem": "^6.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Finder\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Finds files and directories via an intuitive fluent interface", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/finder/tree/v6.3.5" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-09-26T12:56:25+00:00" + }, { "name": "symfony/options-resolver", "version": "v6.3.0", diff --git a/examples/bootstrap.php b/examples/bootstrap.php index fcd170acf..1f5978e36 100644 --- a/examples/bootstrap.php +++ b/examples/bootstrap.php @@ -6,11 +6,13 @@ \ini_set('memory_limit', -1); -const __FLOW_DATA__ = __DIR__ . '/data'; -const __FLOW_OUTPUT__ = __DIR__ . '/output'; -const __FLOW_VAR__ = __DIR__ . '/var'; -const __FLOW_VAR_RUN__ = __DIR__ . '/var/run'; -const __FLOW_SRC__ = __DIR__ . '/../src'; +if (!\defined('__FLOW_DATA__')) { + \define('__FLOW_DATA__', __DIR__ . '/data'); + \define('__FLOW_OUTPUT__', __DIR__ . '/output'); + \define('__FLOW_VAR__', __DIR__ . '/var'); + \define('__FLOW_VAR_RUN__', __DIR__ . '/var/run'); + \define('__FLOW_SRC__', __DIR__ . '/../src'); +} if (!\is_dir(__FLOW_VAR__)) { \mkdir(__FLOW_VAR__); diff --git a/examples/run_examples.php b/examples/run_examples.php new file mode 100755 index 000000000..76b3df937 --- /dev/null +++ b/examples/run_examples.php @@ -0,0 +1,39 @@ +#!/usr/bin/env php +in(__DIR__ . '/topics') + // async & database examples require additional manual setup to be run properly + ->exclude([__DIR__ . '/topics/async', __DIR__ . '/topics/db']) + ->files() + ->name('*.php'); + +foreach ($finder as $file) { + print "\nExample: {$file->getRelativePathname()}\n"; + + try { + include $file->getRealPath(); + } catch (\Exception $e) { + print "Example failed: {$e->getMessage()}\n"; + } +}