Page MenuHomePhabricator

D568.id1990.diff
No OneTemporary

D568.id1990.diff

diff --git a/app/services/router/RouteProvider.php b/app/services/router/RouteProvider.php
new file mode 100644
--- /dev/null
+++ b/app/services/router/RouteProvider.php
@@ -0,0 +1,64 @@
+<?php namespace app\services\router;
+
+use spitfire\service\Provider;
+
+/*
+ * The MIT License
+ *
+ * Copyright 2021 César de la Cal Bretschneider <cesar@magic3w.com>.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+class RouteProvider extends Provider
+{
+
+
+ public function register()
+ {
+ #This provider actually just loads routes and does not register any services
+ }
+
+ public function init()
+ {
+ /*
+ * Locate the current application's root directory. This is a quirky way
+ * of finding the file, but it's a requirement, since composer won't let us
+ * know where we are, and what the package root is.
+ */
+ $approot = realpath('../../../');
+
+ /*
+ * We also need access to the router
+ */
+ $app = spitfire()->cluster()->findAppForClass(__CLASS__);
+ $router = $app->router();
+
+ /*
+ * Within this, we want to load our two routes files, routes.web and routes.api
+ *
+ * Please note that we expect these files to return a closure that accepts
+ * the router as parameter and then can pass our scoped router to these closures
+ * so they append the routes to the appropriate url spaces.
+ */
+ (include_once $approot . 'resources/routes.api.php')($router);
+ (include_once $approot . 'resources/routes.web.php')($router);
+ }
+
+}
diff --git a/config/app.php b/config/app.php
new file mode 100644
--- /dev/null
+++ b/config/app.php
@@ -0,0 +1,7 @@
+<?php
+
+return [
+ 'providers' => [
+ \app\services\router\RouteProvider::class
+ ]
+];
diff --git a/config/cache.php b/config/cache.php
new file mode 100644
--- /dev/null
+++ b/config/cache.php
@@ -0,0 +1,7 @@
+<?php
+
+return [
+ 'memcached' => [
+ 'server' => 'localhost'
+ ]
+];
diff --git a/config/commands.php b/config/commands.php
deleted file mode 100644
--- a/config/commands.php
+++ /dev/null
@@ -1,13 +0,0 @@
-<?php
-
-/*
- * Includes the built in commands that Spitfire provides so internal functionality
- * can be provided.
- */
-include_once BASE_DIR . '/vendor/spitfire/engine/config/commands.php';
-
-
-/*
- * Define your command line interface commands in here, when invoking the appropriate
- * command, Spitfire will call the director you requested.
- */
diff --git a/config/database/mysql.php b/config/database/mysql.php
new file mode 100644
--- /dev/null
+++ b/config/database/mysql.php
@@ -0,0 +1,5 @@
+<?php
+
+return [
+ 'server' => 'localhost'
+];
diff --git a/config/routes.api.php b/config/routes.api.php
deleted file mode 100644
--- a/config/routes.api.php
+++ /dev/null
@@ -1,5 +0,0 @@
-<?php
-
-/**
- * Define all your routes in this file.
- */
\ No newline at end of file
diff --git a/config/routes.web.php b/config/routes.web.php
deleted file mode 100644
--- a/config/routes.web.php
+++ /dev/null
@@ -1,5 +0,0 @@
-<?php
-
-/**
- * Define all your routes in this file.
- */
diff --git a/nbproject/project.properties b/nbproject/project.properties
--- a/nbproject/project.properties
+++ b/nbproject/project.properties
@@ -1,5 +1,6 @@
include.path=${php.global.include.path}
php.version=PHP_74
+project.license=mit
source.encoding=UTF-8
src.dir=.
tags.asp=false
diff --git a/public/index.php b/public/index.php
--- a/public/index.php
+++ b/public/index.php
@@ -14,11 +14,11 @@
/*
* Include Spitfire core.
*/
-include __DIR__ . '/../app/bootstrap.php';
include BASEDIR . '/vendor/autoload.php';
+include __DIR__ . '/../app/bootstrap.php';
/*
* Spitfire will retrieve the request from the web server, select the appropriate
* controller and invoke the middleware.
*/
spitfire()->fire();
\ No newline at end of file
diff --git a/resources/commands.php b/resources/commands.php
new file mode 100644
--- /dev/null
+++ b/resources/commands.php
@@ -0,0 +1,6 @@
+<?php
+
+/*
+ * Define your command line interface commands in here, when invoking the appropriate
+ * command, Spitfire will call the director you requested.
+ */
diff --git a/resources/routes.api.php b/resources/routes.api.php
new file mode 100644
--- /dev/null
+++ b/resources/routes.api.php
@@ -0,0 +1,21 @@
+<?php
+
+use spitfire\core\router\Router;
+
+
+/**
+ * Feel free to add your routes inside this closure. This ensures that the
+ * application can load it and appropriately scope your routes to function
+ * within it's selected URL space (not unlike a directory).
+ *
+ * This file is focused on providing API style access to your application,
+ * without interfering with your user facing service.
+ *
+ * You can write different versions of the API like this:
+ *
+ * $v1 = $router->scope('api/v1');
+ * $v1->route(...);
+ */
+return function (Router $router) {
+
+};
\ No newline at end of file
diff --git a/resources/routes.web.php b/resources/routes.web.php
new file mode 100644
--- /dev/null
+++ b/resources/routes.web.php
@@ -0,0 +1,14 @@
+<?php
+
+use spitfire\core\router\Router;
+
+
+/**
+ * Feel free to add your routes inside this closure. This ensures that the
+ * application can load it and appropriately scope your routes to function
+ * within it's selected URL space (not unlike a directory).
+ */
+return function (Router $router) {
+
+};
+
\ No newline at end of file

File Metadata

Mime Type
text/plain
Expires
Wed, Apr 14, 6:49 AM (3 w, 6 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5939
Default Alt Text
D568.id1990.diff (6 KB)

Event Timeline