* initial commit
* get list of activities * get activity by id
This commit is contained in:
2
config/autoload/.gitignore
vendored
Normal file
2
config/autoload/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
local.php
|
||||
*.local.php
|
||||
25
config/autoload/dependencies.global.php
Normal file
25
config/autoload/dependencies.global.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
use Zend\Expressive\Application;
|
||||
use Zend\Expressive\Container\ApplicationFactory;
|
||||
use Zend\Expressive\Helper;
|
||||
|
||||
return [
|
||||
// Provides application-wide services.
|
||||
// We recommend using fully-qualified class names whenever possible as
|
||||
// service names.
|
||||
'dependencies' => [
|
||||
// Use 'invokables' for constructor-less services, or services that do
|
||||
// not require arguments to the constructor. Map a service name to the
|
||||
// class name.
|
||||
'invokables' => [
|
||||
// Fully\Qualified\InterfaceName::class => Fully\Qualified\ClassName::class,
|
||||
Helper\ServerUrlHelper::class => Helper\ServerUrlHelper::class,
|
||||
],
|
||||
// Use 'factories' for services provided by callbacks/factory classes.
|
||||
'factories' => [
|
||||
Application::class => ApplicationFactory::class,
|
||||
Helper\UrlHelper::class => Helper\UrlHelperFactory::class,
|
||||
\App\Service\SkiesService::class => \App\Service\SkiesServiceFactory::class,
|
||||
],
|
||||
],
|
||||
];
|
||||
7
config/autoload/local.dist.php
Normal file
7
config/autoload/local.dist.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'authKey' => '',
|
||||
'debug' => true,
|
||||
'config_cache_enabled' => false,
|
||||
];
|
||||
69
config/autoload/middleware-pipeline.global.php
Normal file
69
config/autoload/middleware-pipeline.global.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
use Zend\Expressive\Container\ApplicationFactory;
|
||||
use Zend\Expressive\Helper;
|
||||
|
||||
return [
|
||||
'dependencies' => [
|
||||
'factories' => [
|
||||
Helper\ServerUrlMiddleware::class => Helper\ServerUrlMiddlewareFactory::class,
|
||||
Helper\UrlHelperMiddleware::class => Helper\UrlHelperMiddlewareFactory::class,
|
||||
],
|
||||
],
|
||||
// This can be used to seed pre- and/or post-routing middleware
|
||||
'middleware_pipeline' => [
|
||||
// An array of middleware to register. Each item is of the following
|
||||
// specification:
|
||||
//
|
||||
// [
|
||||
// Required:
|
||||
// 'middleware' => 'Name or array of names of middleware services and/or callables',
|
||||
// Optional:
|
||||
// 'path' => '/path/to/match', // string; literal path prefix to match
|
||||
// // middleware will not execute
|
||||
// // if path does not match!
|
||||
// 'error' => true, // boolean; true for error middleware
|
||||
// 'priority' => 1, // int; higher values == register early;
|
||||
// // lower/negative == register last;
|
||||
// // default is 1, if none is provided.
|
||||
// ],
|
||||
//
|
||||
// While the ApplicationFactory ignores the keys associated with
|
||||
// specifications, they can be used to allow merging related values
|
||||
// defined in multiple configuration files/locations. This file defines
|
||||
// some conventional keys for middleware to execute early, routing
|
||||
// middleware, and error middleware.
|
||||
'always' => [
|
||||
'middleware' => [
|
||||
// Add more middleware here that you want to execute on
|
||||
// every request:
|
||||
// - bootstrapping
|
||||
// - pre-conditions
|
||||
// - modifications to outgoing responses
|
||||
Helper\ServerUrlMiddleware::class,
|
||||
],
|
||||
'priority' => 10000,
|
||||
],
|
||||
|
||||
'routing' => [
|
||||
'middleware' => [
|
||||
ApplicationFactory::ROUTING_MIDDLEWARE,
|
||||
Helper\UrlHelperMiddleware::class,
|
||||
// Add more middleware here that needs to introspect the routing
|
||||
// results; this might include:
|
||||
// - route-based authentication
|
||||
// - route-based validation
|
||||
// - etc.
|
||||
ApplicationFactory::DISPATCH_MIDDLEWARE,
|
||||
],
|
||||
'priority' => 1,
|
||||
],
|
||||
|
||||
'error' => [
|
||||
'middleware' => [
|
||||
// Add error middleware here.
|
||||
],
|
||||
'error' => true,
|
||||
'priority' => -10000,
|
||||
],
|
||||
],
|
||||
];
|
||||
41
config/autoload/routes.global.php
Normal file
41
config/autoload/routes.global.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'dependencies' => [
|
||||
'invokables' => [
|
||||
Zend\Expressive\Router\RouterInterface::class => Zend\Expressive\Router\FastRouteRouter::class,
|
||||
App\Action\PingAction::class => App\Action\PingAction::class,
|
||||
],
|
||||
'factories' => [
|
||||
App\Action\HomePageAction::class => App\Action\HomePageFactory::class,
|
||||
App\Action\ActivityAction::class => App\Action\ActivityFactory::class,
|
||||
],
|
||||
],
|
||||
|
||||
'routes' => [
|
||||
[
|
||||
'name' => 'home',
|
||||
'path' => '/',
|
||||
'middleware' => App\Action\HomePageAction::class,
|
||||
'allowed_methods' => ['GET'],
|
||||
],
|
||||
[
|
||||
'name' => 'api.ping',
|
||||
'path' => '/api/ping',
|
||||
'middleware' => App\Action\PingAction::class,
|
||||
'allowed_methods' => ['GET'],
|
||||
],
|
||||
[
|
||||
'name' => 'api.activity',
|
||||
'path' => '/api/activity',
|
||||
'middleware' => App\Action\ActivityAction::class,
|
||||
'allowed_methods' => ['GET', 'POST', 'DELETE', 'OPTIONS'],
|
||||
],
|
||||
[
|
||||
'name' => 'api.activity.id',
|
||||
'path' => '/api/activity/{id:\d+}',
|
||||
'middleware' => App\Action\ActivityAction::class,
|
||||
'allowed_methods' => ['GET', 'PUT', 'DELETE', 'OPTIONS'],
|
||||
],
|
||||
],
|
||||
];
|
||||
14
config/autoload/zend-expressive.global.php
Normal file
14
config/autoload/zend-expressive.global.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'debug' => false,
|
||||
|
||||
'config_cache_enabled' => false,
|
||||
|
||||
'zend-expressive' => [
|
||||
'error_handler' => [
|
||||
'template_404' => 'error::404',
|
||||
'template_error' => 'error::error',
|
||||
],
|
||||
],
|
||||
];
|
||||
35
config/config.php
Normal file
35
config/config.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Zend\Stdlib\ArrayUtils;
|
||||
use Zend\Stdlib\Glob;
|
||||
|
||||
/**
|
||||
* Configuration files are loaded in a specific order. First ``global.php``, then ``*.global.php``.
|
||||
* then ``local.php`` and finally ``*.local.php``. This way local settings overwrite global settings.
|
||||
*
|
||||
* The configuration can be cached. This can be done by setting ``config_cache_enabled`` to ``true``.
|
||||
*
|
||||
* Obviously, if you use closures in your config you can't cache it.
|
||||
*/
|
||||
|
||||
$cachedConfigFile = 'data/cache/app_config.php';
|
||||
|
||||
$config = [];
|
||||
if (is_file($cachedConfigFile)) {
|
||||
// Try to load the cached config
|
||||
$config = include $cachedConfigFile;
|
||||
} else {
|
||||
// Load configuration from autoload path
|
||||
foreach (Glob::glob('config/autoload/{{,*.}global,{,*.}local}.php', Glob::GLOB_BRACE) as $file) {
|
||||
$config = ArrayUtils::merge($config, include $file);
|
||||
}
|
||||
|
||||
// Cache config if enabled
|
||||
if (isset($config['config_cache_enabled']) && $config['config_cache_enabled'] === true) {
|
||||
file_put_contents($cachedConfigFile, '<?php return ' . var_export($config, true) . ';');
|
||||
}
|
||||
}
|
||||
|
||||
// Return an ArrayObject so we can inject the config as a service in Aura.Di
|
||||
// and still use array checks like ``is_array``.
|
||||
return new ArrayObject($config, ArrayObject::ARRAY_AS_PROPS);
|
||||
16
config/container.php
Normal file
16
config/container.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
use Zend\ServiceManager\Config;
|
||||
use Zend\ServiceManager\ServiceManager;
|
||||
|
||||
// Load configuration
|
||||
$config = require __DIR__ . '/config.php';
|
||||
|
||||
// Build container
|
||||
$container = new ServiceManager();
|
||||
(new Config($config['dependencies']))->configureServiceManager($container);
|
||||
|
||||
// Inject config
|
||||
$container->setService('config', $config);
|
||||
|
||||
return $container;
|
||||
Reference in New Issue
Block a user