* added doctrine config template

* added loslog template
* removed unused  license files
* added log dir
This commit is contained in:
Danyi Dávid 2020-12-25 21:32:01 +01:00
parent 389e453a56
commit 8bca2fbe82
8 changed files with 137 additions and 119 deletions

View File

@ -1 +0,0 @@
Copyright (c) 2020 Laminas Project a Series of LF Projects, LLC. (https://getlaminas.org/)

View File

@ -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.

115
README.md
View File

@ -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) Use to bootstrap an API backend, with database and logging support using:
[![Coverage Status](https://coveralls.io/repos/github/mezzio/mezzio-skeleton/badge.svg?branch=master)](https://coveralls.io/github/mezzio/mezzio-skeleton?branch=master)
*Begin developing PSR-15 middleware applications in seconds!* * los/loslog
* roave/psr-container-doctrine
[mezzio](https://github.com/mezzio/mezzio) builds on * tuupola/cors-middleware
[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.
## Getting Started ## 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 ```bash
$ composer create-project mezzio/mezzio-skeleton <project-path> $ composer create-project yvan/mezzio-api-skeleton --stability=dev <project-path>
``` ```
After choosing and installing the packages you want, go to the 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. 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 > ### Setting a timeout
> >
> Composer commands time out after 300 seconds (5 minutes). On Linux-based > 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 > $ 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 ## Application Development Mode Tool
This skeleton comes with [laminas-development-mode](https://github.com/laminas/laminas-development-mode). 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 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 the `config/config.php` file and changing the `config_cache_path` entry of the
local `$cacheConfig` variable. 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).

View File

@ -0,0 +1,68 @@
<?php
return [
'doctrine' => [
'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',
],
],
],
],
];

View File

@ -0,0 +1,14 @@
<?php
return [
'doctrine' => [
'connection' => [
'orm_default' => [
'params' => [
'url' => 'sqlite:///data/gallery.db',
'charset' => 'UTF8',
],
],
],
],
];

View File

@ -0,0 +1,30 @@
<?php
declare(strict_types=1);
use Laminas\Stratigility\Middleware\ErrorHandler;
return [
'dependencies' => [
'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,
],
];

2
data/.gitignore vendored
View File

@ -1,4 +1,6 @@
* *
!cache !cache
!cache/.gitkeep !cache/.gitkeep
!logs
!logs/.gitkeep
!.gitignore !.gitignore

0
data/logs/.gitkeep Normal file
View File