diff --git a/.env.dist b/.env.dist index 388e7e1b..2e34016a 100644 --- a/.env.dist +++ b/.env.dist @@ -1,5 +1,7 @@ # Application APP_ENV= +SHORTENED_URL_SCHEMA= +SHORTENED_URL_HOSTNAME= # Database DB_USER= diff --git a/config/autoload/cli-routes.global.php b/config/autoload/cli-routes.global.php index 9a900a7d..c2aafdf1 100644 --- a/config/autoload/cli-routes.global.php +++ b/config/autoload/cli-routes.global.php @@ -1,13 +1,13 @@ [ [ - 'name' => 'cli', - 'path' => '/command-name', - 'middleware' => function ($req, $resp) { - - }, + 'name' => 'cli-generate-shortcode', + 'path' => '/generate-shortcode', + 'middleware' => CliRoutable\GenerateShortcodeMiddleware::class, 'allowed_methods' => ['CLI'], ], ], diff --git a/config/autoload/routes.global.php b/config/autoload/routes.global.php index 48522662..a95711aa 100644 --- a/config/autoload/routes.global.php +++ b/config/autoload/routes.global.php @@ -3,14 +3,12 @@ return [ 'routes' => [ - [ - 'name' => 'home', - 'path' => '/', - 'middleware' => function ($req, $resp) { - - }, - 'allowed_methods' => ['GET'], - ], +// [ +// 'name' => 'home', +// 'path' => '/', +// 'middleware' => '', +// 'allowed_methods' => ['GET'], +// ], ], ]; diff --git a/config/autoload/services.global.php b/config/autoload/services.global.php index 468c4a75..5d47160a 100644 --- a/config/autoload/services.global.php +++ b/config/autoload/services.global.php @@ -1,6 +1,7 @@ [ Application::class => Container\ApplicationFactory::class, - // Routes + // Url helpers Helper\UrlHelper::class => Helper\UrlHelperFactory::class, Helper\ServerUrlMiddleware::class => Helper\ServerUrlMiddlewareFactory::class, Helper\UrlHelperMiddleware::class => Helper\UrlHelperMiddlewareFactory::class, Helper\ServerUrlHelper::class => InvokableFactory::class, - Router\RouterInterface::class => InvokableFactory::class, Router\AuraRouter::class => InvokableFactory::class, // View @@ -36,10 +36,14 @@ return [ GuzzleHttp\Client::class => InvokableFactory::class, UrlShortener::class => AnnotatedFactory::class, Cache::class => CacheFactory::class, + + // Middleware + Middleware\CliRoutable\GenerateShortcodeMiddleware::class => AnnotatedFactory::class, ], 'aliases' => [ 'em' => EntityManager::class, 'httpClient' => GuzzleHttp\Client::class, + Router\RouterInterface::class => Router\AuraRouter::class, ] ], diff --git a/config/autoload/url-shortener.global.php b/config/autoload/url-shortener.global.php new file mode 100644 index 00000000..795ce021 --- /dev/null +++ b/config/autoload/url-shortener.global.php @@ -0,0 +1,9 @@ + [ + 'schema' => getenv('SHORTENED_URL_SCHEMA') ?: 'http', + 'hostname' => getenv('SHORTENED_URL_HOSTNAME'), + ], + +]; diff --git a/config/config.php b/config/config.php index 4838f371..a3d0e7ac 100644 --- a/config/config.php +++ b/config/config.php @@ -29,6 +29,4 @@ if (is_file($cachedConfigFile)) { } } -// 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); +return $config; diff --git a/src/Entity/ShortUrl.php b/src/Entity/ShortUrl.php index 994f2e2f..35c7ed1b 100644 --- a/src/Entity/ShortUrl.php +++ b/src/Entity/ShortUrl.php @@ -27,7 +27,7 @@ class ShortUrl extends AbstractEntity protected $shortCode; /** * @var \DateTime - * @ORM\Column(name="date_created", ) + * @ORM\Column(name="date_created", type="datetime") */ protected $dateCreated; /**