From 8bca2fbe826ef37f6059794c96361cdf9a66d6c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danyi=20D=C3=A1vid?= Date: Fri, 25 Dec 2020 21:32:01 +0100 Subject: [PATCH] * added doctrine config template * added loslog template * removed unused license files * added log dir --- COPYRIGHT.md | 1 - LICENSE.md | 26 ------ README.md | 115 +++++------------------- config/autoload/doctrine.global.php | 68 ++++++++++++++ config/autoload/doctrine.local.dist.php | 14 +++ config/autoload/loslog.global.php | 30 +++++++ data/.gitignore | 2 + data/logs/.gitkeep | 0 8 files changed, 137 insertions(+), 119 deletions(-) delete mode 100644 COPYRIGHT.md delete mode 100644 LICENSE.md create mode 100644 config/autoload/doctrine.global.php create mode 100644 config/autoload/doctrine.local.dist.php create mode 100644 config/autoload/loslog.global.php create mode 100644 data/logs/.gitkeep diff --git a/COPYRIGHT.md b/COPYRIGHT.md deleted file mode 100644 index 0a8cccc..0000000 --- a/COPYRIGHT.md +++ /dev/null @@ -1 +0,0 @@ -Copyright (c) 2020 Laminas Project a Series of LF Projects, LLC. (https://getlaminas.org/) diff --git a/LICENSE.md b/LICENSE.md deleted file mode 100644 index 10b40f1..0000000 --- a/LICENSE.md +++ /dev/null @@ -1,26 +0,0 @@ -Copyright (c) 2020 Laminas Project a Series of LF Projects, LLC. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -- Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -- Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -- Neither the name of Laminas Foundation nor the names of its contributors may - be used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md index 79da083..128fa6d 100644 --- a/README.md +++ b/README.md @@ -1,33 +1,33 @@ -# Mezzio Skeleton and Installer +# Mezzio API Skeleton -[![Build Status](https://travis-ci.com/mezzio/mezzio-skeleton.svg?branch=master)](https://travis-ci.com/mezzio/mezzio-skeleton) -[![Coverage Status](https://coveralls.io/repos/github/mezzio/mezzio-skeleton/badge.svg?branch=master)](https://coveralls.io/github/mezzio/mezzio-skeleton?branch=master) +Use to bootstrap an API backend, with database and logging support using: -*Begin developing PSR-15 middleware applications in seconds!* - -[mezzio](https://github.com/mezzio/mezzio) builds on -[laminas-stratigility](https://github.com/laminas/laminas-stratigility) to -provide a minimalist PSR-15 middleware framework for PHP with routing, DI -container, optional templating, and optional error handling capabilities. - -This installer will setup a skeleton application based on mezzio by -choosing optional packages based on user input as demonstrated in the following -screenshot: - -![screenshot-installer](https://user-images.githubusercontent.com/1011217/90332191-55d32200-dfbb-11ea-80c0-27a07ef5691a.png) - -The user selected packages are saved into `composer.json` so that everyone else -working on the project have the same packages installed. Configuration files and -templates are prepared for first use. The installer command is removed from -`composer.json` after setup succeeded, and all installer related files are -removed. +* los/loslog +* roave/psr-container-doctrine +* tuupola/cors-middleware ## Getting Started -Start your new Mezzio project with composer: +You'll have to add the VCS to your composer config.json: +```bash +$ cat ~/.composer/config.json +``` +```json +{ + "config": {}, + "repositories": [ + { + "type": "vcs", + "url": "https://gogs.ragnarok.yvan.hu/yvan/mezzio-api-skeleton.git" + } + ] +} +``` + +Start your new API project with composer: ```bash -$ composer create-project mezzio/mezzio-skeleton +$ composer create-project yvan/mezzio-api-skeleton --stability=dev ``` After choosing and installing the packages you want, go to the @@ -39,18 +39,6 @@ $ composer run --timeout=0 serve You can then browse to http://localhost:8080. -> ### Linux users -> -> On PHP versions prior to 7.1.14 and 7.2.2, this command might not work as -> expected due to a bug in PHP that only affects linux environments. In such -> scenarios, you will need to start the [built-in web -> server](http://php.net/manual/en/features.commandline.webserver.php) yourself, -> using the following command: -> -> ```bash -> $ php -S 0.0.0.0:8080 -t public/ public/index.php -> ``` - > ### Setting a timeout > > Composer commands time out after 300 seconds (5 minutes). On Linux-based @@ -68,43 +56,6 @@ You can then browse to http://localhost:8080. > $ composer run --timeout=86400 serve > ``` -## Installing alternative packages - -There is a feature to install alternative packages: Instead of entering one of -the selection **you can actually type the package name and version**. - -> ``` -> Which template engine do you want to use? -> [1] Plates -> [2] Twig -> [3] zend-view installs zend-servicemanager -> [n] None of the above -> Make your selection or type a composer package name and version (n): infw/pug:0.1 -> - Searching for infw/pug:0.1 -> - Adding package infw/pug (0.1) -> ``` - -That feature allows you to install any alternative package you want. It has its limitations though: - -* The alternative package must follow this format `namespace/package:1.0`. It needs the correct version. -* Templates are not copied, but the ConfigProvider can be configured in such way that it uses the - default templates directly from the package itself. -* This doesn't work for containers as the container.php file needs to be copied. - -## Troubleshooting - -If the installer fails during the ``composer create-project`` phase, please go -through the following list before opening a new issue. Most issues we have seen -so far can be solved by `self-update` and `clear-cache`. - -1. Be sure to work with the latest version of composer by running `composer self-update`. -2. Try clearing Composer's cache by running `composer clear-cache`. - -If neither of the above help, you might face more serious issues: - -- Info about the [zlib_decode error](https://github.com/composer/composer/issues/4121). -- Info and solutions for [composer degraded mode](https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode). - ## Application Development Mode Tool This skeleton comes with [laminas-development-mode](https://github.com/laminas/laminas-development-mode). @@ -151,23 +102,3 @@ $ composer clear-config-cache You may also change the location of the configuration cache itself by editing the `config/config.php` file and changing the `config_cache_path` entry of the local `$cacheConfig` variable. - -## Skeleton Development - -This section applies only if you cloned this repo with `git clone`, not when you -installed mezzio with `composer create-project ...`. - -If you want to run tests against the installer, you need to clone this repo and -setup all dependencies with composer. Make sure you **prevent composer running -scripts** with `--no-scripts`, otherwise it will remove the installer and all -tests. - -```bash -$ composer update --no-scripts -$ composer test -``` - -Please note that the installer tests remove installed config files and templates -before and after running the tests. - -Before contributing read [the contributing guide](https://github.com/mezzio/.github/blob/master/CONTRIBUTING.md). diff --git a/config/autoload/doctrine.global.php b/config/autoload/doctrine.global.php new file mode 100644 index 0000000..3f7e720 --- /dev/null +++ b/config/autoload/doctrine.global.php @@ -0,0 +1,68 @@ + [ + 'driver' => [ + 'orm_default' => [ + 'class' => \Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain::class, + 'drivers' => [ + 'App\Entity' => 'app_entity', + ], + ], + 'app_entity' => [ + 'class' => \Doctrine\ORM\Mapping\Driver\AnnotationDriver::class, + 'cache' => 'array', + 'paths' => __DIR__ . '/../../src/App/Entity', + ], + ], + 'configuration' => [ + 'orm_default' => [ +// 'datetime_functions' => [ +// 'date' => Oro\ORM\Query\AST\Functions\SimpleFunction::class, +// 'time' => Oro\ORM\Query\AST\Functions\SimpleFunction::class, +// 'timestamp' => Oro\ORM\Query\AST\Functions\SimpleFunction::class, +// 'convert_tz' => Oro\ORM\Query\AST\Functions\DateTime\ConvertTz::class, +// ], +// 'numeric_functions' => [ +// 'timestampdiff' => Oro\ORM\Query\AST\Functions\Numeric\TimestampDiff::class, +// 'dayofyear' => Oro\ORM\Query\AST\Functions\SimpleFunction::class, +// 'dayofmonth' => Oro\ORM\Query\AST\Functions\SimpleFunction::class, +// 'dayofweek' => Oro\ORM\Query\AST\Functions\SimpleFunction::class, +// 'week' => Oro\ORM\Query\AST\Functions\SimpleFunction::class, +// 'day' => Oro\ORM\Query\AST\Functions\SimpleFunction::class, +// 'hour' => Oro\ORM\Query\AST\Functions\SimpleFunction::class, +// 'minute' => Oro\ORM\Query\AST\Functions\SimpleFunction::class, +// 'month' => Oro\ORM\Query\AST\Functions\SimpleFunction::class, +// 'quarter' => Oro\ORM\Query\AST\Functions\SimpleFunction::class, +// 'second' => Oro\ORM\Query\AST\Functions\SimpleFunction::class, +// 'year' => Oro\ORM\Query\AST\Functions\SimpleFunction::class, +// 'sign' => Oro\ORM\Query\AST\Functions\Numeric\Sign::class, +// 'pow' => Oro\ORM\Query\AST\Functions\Numeric\Pow::class, +// ], +// 'string_functions' => [ +// 'md5' => Oro\ORM\Query\AST\Functions\SimpleFunction::class, +// 'group_concat' => Oro\ORM\Query\AST\Functions\String\GroupConcat::class, +// 'cast' => Oro\ORM\Query\AST\Functions\Cast::class, +// 'concat_ws' => Oro\ORM\Query\AST\Functions\String\ConcatWs::class +// ] +// 'filters' => [ +// 'soft-deleteable' => Gedmo\SoftDeleteable\Filter\SoftDeleteableFilter::class, +// ], + ], + ], + 'event_manager' => [ + 'orm_default' => [ + 'subscribers' => [ + // Gedmo\Timestampable\TimestampableListener::class, + // 'Gedmo\Tree\TreeListener', + // 'Gedmo\SoftDeleteable\SoftDeleteableListener', + // 'Gedmo\Translatable\TranslatableListener', + // 'Gedmo\Blameable\BlameableListener', + // 'Gedmo\Loggable\LoggableListener', + // 'Gedmo\Sortable\SortableListener', + // 'Gedmo\Sluggable\SluggableListener', + ], + ], + ], + ], +]; diff --git a/config/autoload/doctrine.local.dist.php b/config/autoload/doctrine.local.dist.php new file mode 100644 index 0000000..d21cb8b --- /dev/null +++ b/config/autoload/doctrine.local.dist.php @@ -0,0 +1,14 @@ + [ + 'connection' => [ + 'orm_default' => [ + 'params' => [ + 'url' => 'sqlite:///data/gallery.db', + 'charset' => 'UTF8', + ], + ], + ], + ], +]; diff --git a/config/autoload/loslog.global.php b/config/autoload/loslog.global.php new file mode 100644 index 0000000..e210009 --- /dev/null +++ b/config/autoload/loslog.global.php @@ -0,0 +1,30 @@ + [ + 'factories' => [ + LosMiddleware\LosLog\LosLog::class => LosMiddleware\LosLog\LosLogFactory::class, + LosMiddleware\LosLog\HttpLog::class => LosMiddleware\LosLog\HttpLogFactory::class, + Psr\Log\LoggerInterface::class => LosMiddleware\LosLog\LoggerFactory::class, + ], + 'delegators' => [ + ErrorHandler::class => [ + LosMiddleware\LosLog\ErrorHandlerListenerDelegatorFactory::class, + ], + ], + ], + 'loslog' => [ + 'log_dir' => 'data/logs', + 'error_logger_file' => 'error.log', + 'exception_logger_file' => 'exception.log', + 'static_logger_file' => 'static.log', + 'http_logger_file' => 'http.log', + 'log_request' => false, + 'log_response' => false, + 'full' => false, + ], +]; diff --git a/data/.gitignore b/data/.gitignore index 5381e79..f29a1ef 100644 --- a/data/.gitignore +++ b/data/.gitignore @@ -1,4 +1,6 @@ * !cache !cache/.gitkeep +!logs +!logs/.gitkeep !.gitignore diff --git a/data/logs/.gitkeep b/data/logs/.gitkeep new file mode 100644 index 0000000..e69de29