Commits

Stepan Anchugov committed 7b6d44d

[add] Kernel stuff
[add] PHPUnit env

Comments (0)

Files changed (13)

app/AppKernel.php

+<?php
+/**
+ * @author Stepan Anchugov <kixxx1@gmail.com>
+ */
+class AppKernel
+{
+
+}

app/bootstrap.php

+<?php
+/**
+ * @author Stepan Anchugov <kixxx1@gmail.com>
+ */
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- http://www.phpunit.de/manual/current/en/appendixes.configuration.html -->
+<phpunit
+    backupGlobals               = "false"
+    backupStaticAttributes      = "false"
+    colors                      = "true"
+    convertErrorsToExceptions   = "true"
+    convertNoticesToExceptions  = "true"
+    convertWarningsToExceptions = "true"
+    processIsolation            = "false"
+    stopOnFailure               = "false"
+    syntaxCheck                 = "false"
+    bootstrap                   = "bootstrap.php.cache" >
+
+    <testsuites>
+        <testsuite name="Project Test Suite">
+            <directory>../src/*/*Bundle/Tests</directory>
+            <directory>../src/*/Bundle/*Bundle/Tests</directory>
+        </testsuite>
+    </testsuites>
+
+    <!--
+    <php>
+        <server name="KERNEL_DIR" value="/path/to/your/app/" />
+    </php>
+    -->
+
+    <filter>
+        <whitelist>
+            <directory>../src</directory>
+            <exclude>
+                <directory>../src/*/*Bundle/Resources</directory>
+                <directory>../src/*/*Bundle/Tests</directory>
+                <directory>../src/*/Bundle/*Bundle/Resources</directory>
+                <directory>../src/*/Bundle/*Bundle/Tests</directory>
+            </exclude>
+        </whitelist>
+    </filter>
+
+</phpunit>

composer.json

Empty file added.

src/Kix/Framework/Kernel.php

+<?php
+namespace Kix\Framework;
+
+use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpFoundation\Response;
+
+/**
+ * Ядро приложения
+ *
+ * @author Stepan Anchugov <kixxx1@gmail.com>
+ */
+abstract class Kernel
+{
+
+    /**
+     * @var array
+     */
+    private $_packages;
+
+    /**
+     * @var Router
+     */
+    private $_router;
+
+    /**
+     * Собираем все пэкеджи, регистрируем роуты из них
+     */
+    public function __construct()
+    {
+        $this->initPackages();
+
+        $this->_router = new Router();
+    }
+
+    protected function addPackage(Package $package)
+    {
+        $this->_packages []= $package;
+        $this->_router->addRoutes($package->getRoutes());
+    }
+
+    /**
+     * В наследнике описываются пакеты, которые мы собираемся подключать
+     * @return mixed
+     */
+    abstract public function initPackages();
+
+    /**
+     * @param Request $request
+     * @return Response
+     */
+    public function handle($request)
+    {
+
+    }
+
+}

src/Kix/Framework/Package.php

+<?php
+namespace Kix\Framework;
+
+/**
+ * @author Stepan Anchugov <kixxx1@gmail.com>
+ */
+class Package
+{
+
+    protected $reflected;
+
+    public function getPath()
+    {
+        $reflected = new \ReflectionObject($this);
+        return dirname($reflected->getFileName());
+    }
+
+    /**
+     * In ideal world this should be done via DI
+     */
+    public function getRoutes()
+    {
+        $path = $this->getPath();
+        var_dump($path); die;
+    }
+
+}

src/Kix/Framework/Router.php

+<?php
+namespace Kix\Framework;
+
+/**
+ * @author Stepan Anchugov <kixxx1@gmail.com>
+ */
+class Router
+{
+
+    /**
+     * @var
+     */
+    private $routes;
+
+    public function addRoute()
+    {
+
+    }
+
+}

src/Kix/Framework/Router/Route.php

+<?php
+namespace Kix\Framework\Router;
+
+/**
+ * @author Stepan Anchugov <kixxx1@gmail.com>
+ */
+class Route
+{
+
+    /**
+     * Regex
+     *
+     * @var string
+     */
+    private $pattern;
+
+    /**
+     * e.g. SomeController::someAction
+     *
+     * @var string
+     */
+    private $target;
+
+}

src/Kix/Framework/Tests/PackageTest.php

+<?php
+namespace Kix\Framework\Tests;
+
+use Kix\Framework\Package;
+
+/**
+ * @author Stepan Anchugov <kixxx1@gmail.com>
+ */
+class PackageTest extends \PHPUnit_Framework_TestCase
+{
+
+    public function testGetPath()
+    {
+        $package = new Package();
+        $this->assertEquals('/src/Kix/Framework', substr($package->getPath(), -18));
+    }
+
+    public function testGetRoutes()
+    {
+        $
+    }
+
+}

src/Kix/MovieDb/MovieDb.php

+<?php
+/**
+ * @author Stepan Anchugov <kixxx1@gmail.com>
+ */
+class MovieDb
+{
+
+}

src/Kix/MovieDb/Resources/config/routes.php

+<?php
+/**
+ * @author Stepan Anchugov <kixxx1@gmail.com>
+ */

src/Kix/MovieDb/Resources/config/routes.yml

Empty file added.
Empty file added.