diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..932b431 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*~ +.idea/ +vendor/ diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..9f9b9b2 --- /dev/null +++ b/.htaccess @@ -0,0 +1,49 @@ +# Use the front controller as index file. It serves as a fallback solution when +# every other rewrite/redirect fails (e.g. in an aliased environment without +# mod_rewrite). Additionally, this reduces the matching process for the +# start page (path "/") because otherwise Apache will apply the rewriting rules +# to each configured DirectoryIndex file (e.g. index.php, index.html, index.pl). +DirectoryIndex index.php + +RewriteEngine On +# Determine the RewriteBase automatically and set it as environment variable. +# If you are using Apache aliases to do mass virtual hosting or installed the +# project in a subdirectory, the base path will be prepended to allow proper +# resolution of the index.php file and to redirect to the correct URI. It will +# work in environments without path prefix as well, providing a safe, one-size +# fits all solution. But as you do not need it in this case, you can comment +# the following 2 lines to eliminate the overhead. +RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$ +RewriteRule ^(.*) - [E=BASE:%1] +# Sets the HTTP_AUTHORIZATION header removed by apache +RewriteCond %{HTTP:Authorization} . +RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] +# Redirect to URI without front controller to prevent duplicate content +# (with and without `/index.php`). Only do this redirect on the initial +# rewrite by Apache and not on subsequent cycles. Otherwise we would get an +# endless redirect loop (request -> rewrite to front controller -> +# redirect -> request -> ...). +# So in case you get a "too many redirects" error or you always get redirected +# to the start page because your Apache does not expose the REDIRECT_STATUS +# environment variable, you have 2 choices: +# - disable this feature by commenting the following 2 lines or +# - use Apache >= 2.3.9 and replace all L flags by END flags and remove the +# following RewriteCond (best solution) +RewriteCond %{ENV:REDIRECT_STATUS} ^$ +RewriteRule ^app\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L] +# If the requested filename exists, simply serve it. +# We only want to let Apache serve files and not directories. +RewriteCond %{REQUEST_FILENAME} -f +RewriteRule .? - [L] +# Rewrite all other queries to the front controller. +RewriteRule .? %{ENV:BASE}/index.php [L] + + + +# When mod_rewrite is not available, we instruct a temporary redirect of +# the start page to the front controller explicitly so that the website +# and the generated links can still be used. +RedirectMatch 302 ^/$ /index.php/ +# RedirectTemp cannot be used instead + + diff --git a/app/views/article.html.twig b/app/views/article.html.twig new file mode 100644 index 0000000..154c80d --- /dev/null +++ b/app/views/article.html.twig @@ -0,0 +1 @@ +{{ method|upper }} Article with "{{ articleId }}" id action diff --git a/app/views/error404.html.twig b/app/views/error404.html.twig new file mode 100644 index 0000000..8c25ff4 --- /dev/null +++ b/app/views/error404.html.twig @@ -0,0 +1,11 @@ + + + + + Base MVC Application - Page not found + + +

404:

+

Page not found on this server

+ + diff --git a/app/views/index.html.twig b/app/views/index.html.twig new file mode 100644 index 0000000..cd08755 --- /dev/null +++ b/app/views/index.html.twig @@ -0,0 +1 @@ +Hello world! diff --git a/app/views/tim.html.twig b/app/views/tim.html.twig new file mode 100644 index 0000000..a4bd2e0 --- /dev/null +++ b/app/views/tim.html.twig @@ -0,0 +1,13 @@ + + + + + Base MVC Application - Football Tim + + +

+

+ +

+ + diff --git a/app/views/tims.html.twig b/app/views/tims.html.twig new file mode 100644 index 0000000..5972266 --- /dev/null +++ b/app/views/tims.html.twig @@ -0,0 +1,14 @@ + + + + + Base MVC Application - Football Tim + + +

Tims

+

+ Tims Champoin + and new Champoin +

+ + diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..45d7543 --- /dev/null +++ b/composer.json @@ -0,0 +1,11 @@ +{ +"autoload": { +"psr-0": {"mvc": "src/"} +}, +"require": { +"symfony/http-foundation": "2.5.6", +"twig/twig": "1.16.2", +"phroute/phroute": "1.4.1", +"phpunit/phpunit": "4.3.4" +} +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..685c304 --- /dev/null +++ b/composer.lock @@ -0,0 +1,917 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "hash": "e97d1bc3d3286339752ba8db1435d022", + "packages": [ + { + "name": "doctrine/instantiator", + "version": "1.0.4", + "source": { + "type": "git", + "url": "https://github.com/doctrine/instantiator.git", + "reference": "f976e5de371104877ebc89bd8fecb0019ed9c119" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/f976e5de371104877ebc89bd8fecb0019ed9c119", + "reference": "f976e5de371104877ebc89bd8fecb0019ed9c119", + "shasum": "" + }, + "require": { + "php": ">=5.3,<8.0-DEV" + }, + "require-dev": { + "athletic/athletic": "~0.1.8", + "ext-pdo": "*", + "ext-phar": "*", + "phpunit/phpunit": "~4.0", + "squizlabs/php_codesniffer": "2.0.*@ALPHA" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "Doctrine\\Instantiator\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "http://ocramius.github.com/" + } + ], + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://github.com/doctrine/instantiator", + "keywords": [ + "constructor", + "instantiate" + ], + "time": "2014-10-13 12:58:55" + }, + { + "name": "phpunit/php-code-coverage", + "version": "2.0.11", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "53603b3c995f5aab6b59c8e08c3a663d2cc810b7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/53603b3c995f5aab6b59c8e08c3a663d2cc810b7", + "reference": "53603b3c995f5aab6b59c8e08c3a663d2cc810b7", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "phpunit/php-file-iterator": "~1.3", + "phpunit/php-text-template": "~1.2", + "phpunit/php-token-stream": "~1.3", + "sebastian/environment": "~1.0", + "sebastian/version": "~1.0" + }, + "require-dev": { + "ext-xdebug": ">=2.1.4", + "phpunit/phpunit": "~4.1" + }, + "suggest": { + "ext-dom": "*", + "ext-xdebug": ">=2.2.1", + "ext-xmlwriter": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "time": "2014-08-31 06:33:04" + }, + { + "name": "phpunit/php-file-iterator", + "version": "1.3.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/acd690379117b042d1c8af1fafd61bde001bf6bb", + "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "File/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "keywords": [ + "filesystem", + "iterator" + ], + "time": "2013-10-10 15:34:57" + }, + { + "name": "phpunit/php-text-template", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", + "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "Text/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "keywords": [ + "template" + ], + "time": "2014-01-30 17:20:04" + }, + { + "name": "phpunit/php-timer", + "version": "1.0.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/19689d4354b295ee3d8c54b4f42c3efb69cbc17c", + "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "PHP/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "time": "2013-08-02 07:42:54" + }, + { + "name": "phpunit/php-token-stream", + "version": "1.3.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-token-stream.git", + "reference": "f8d5d08c56de5cfd592b3340424a81733259a876" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/f8d5d08c56de5cfd592b3340424a81733259a876", + "reference": "f8d5d08c56de5cfd592b3340424a81733259a876", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Wrapper around PHP's tokenizer extension.", + "homepage": "https://github.com/sebastianbergmann/php-token-stream/", + "keywords": [ + "tokenizer" + ], + "time": "2014-08-31 06:12:13" + }, + { + "name": "phpunit/phpunit", + "version": "4.3.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "23e4e0310f037aae873cc81b8658dbbb82878f71" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/23e4e0310f037aae873cc81b8658dbbb82878f71", + "reference": "23e4e0310f037aae873cc81b8658dbbb82878f71", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-json": "*", + "ext-pcre": "*", + "ext-reflection": "*", + "ext-spl": "*", + "php": ">=5.3.3", + "phpunit/php-code-coverage": "~2.0", + "phpunit/php-file-iterator": "~1.3.2", + "phpunit/php-text-template": "~1.2", + "phpunit/php-timer": "~1.0.2", + "phpunit/phpunit-mock-objects": "~2.3", + "sebastian/comparator": "~1.0", + "sebastian/diff": "~1.1", + "sebastian/environment": "~1.0", + "sebastian/exporter": "~1.0", + "sebastian/version": "~1.0", + "symfony/yaml": "~2.0" + }, + "suggest": { + "phpunit/php-invoker": "~1.1" + }, + "bin": [ + "phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.3.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "", + "../../symfony/yaml/" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "The PHP Unit Testing framework.", + "homepage": "http://www.phpunit.de/", + "keywords": [ + "phpunit", + "testing", + "xunit" + ], + "time": "2014-10-22 11:43:12" + }, + { + "name": "phpunit/phpunit-mock-objects", + "version": "2.3.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", + "reference": "c63d2367247365f688544f0d500af90a11a44c65" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/c63d2367247365f688544f0d500af90a11a44c65", + "reference": "c63d2367247365f688544f0d500af90a11a44c65", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "~1.0,>=1.0.1", + "php": ">=5.3.3", + "phpunit/php-text-template": "~1.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.3" + }, + "suggest": { + "ext-soap": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Mock Object library for PHPUnit", + "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", + "keywords": [ + "mock", + "xunit" + ], + "time": "2014-10-03 05:12:11" + }, + { + "name": "phroute/phroute", + "version": "v1.4.1", + "source": { + "type": "git", + "url": "https://github.com/mrjgreen/phroute.git", + "reference": "fd2a2be54171a650df94e03077dfcb851e41d7ec" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mrjgreen/phroute/zipball/fd2a2be54171a650df94e03077dfcb851e41d7ec", + "reference": "fd2a2be54171a650df94e03077dfcb851e41d7ec", + "shasum": "" + }, + "require": { + "php": ">=5.4.0" + }, + "require-dev": { + "satooshi/php-coveralls": "dev-master" + }, + "type": "library", + "autoload": { + "psr-0": { + "Phroute": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Nikita Popov", + "email": "nikic@php.net" + }, + { + "name": "Joe Green", + "email": "joe.green.0991@gmail.com" + } + ], + "description": "Fast request router for PHP", + "keywords": [ + "router", + "routing" + ], + "time": "2014-10-19 13:33:03" + }, + { + "name": "sebastian/comparator", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "e54a01c0da1b87db3c5a3c4c5277ddf331da4aef" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/e54a01c0da1b87db3c5a3c4c5277ddf331da4aef", + "reference": "e54a01c0da1b87db3c5a3c4c5277ddf331da4aef", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "sebastian/diff": "~1.1", + "sebastian/exporter": "~1.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "http://www.github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "time": "2014-05-11 23:00:21" + }, + { + "name": "sebastian/diff", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "5843509fed39dee4b356a306401e9dd1a931fec7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/5843509fed39dee4b356a306401e9dd1a931fec7", + "reference": "5843509fed39dee4b356a306401e9dd1a931fec7", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Diff implementation", + "homepage": "http://www.github.com/sebastianbergmann/diff", + "keywords": [ + "diff" + ], + "time": "2014-08-15 10:29:00" + }, + { + "name": "sebastian/environment", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "0d9bf79554d2a999da194a60416c15cf461eb67d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/0d9bf79554d2a999da194a60416c15cf461eb67d", + "reference": "0d9bf79554d2a999da194a60416c15cf461eb67d", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides functionality to handle HHVM/PHP environments", + "homepage": "http://www.github.com/sebastianbergmann/environment", + "keywords": [ + "Xdebug", + "environment", + "hhvm" + ], + "time": "2014-10-22 06:38:05" + }, + { + "name": "sebastian/exporter", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "c7d59948d6e82818e1bdff7cadb6c34710eb7dc0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/c7d59948d6e82818e1bdff7cadb6c34710eb7dc0", + "reference": "c7d59948d6e82818e1bdff7cadb6c34710eb7dc0", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "http://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ], + "time": "2014-09-10 00:51:36" + }, + { + "name": "sebastian/version", + "version": "1.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "b6e1f0cf6b9e1ec409a0d3e2f2a5fb0998e36b43" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/b6e1f0cf6b9e1ec409a0d3e2f2a5fb0998e36b43", + "reference": "b6e1f0cf6b9e1ec409a0d3e2f2a5fb0998e36b43", + "shasum": "" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version", + "time": "2014-03-07 15:35:33" + }, + { + "name": "symfony/http-foundation", + "version": "v2.5.6", + "target-dir": "Symfony/Component/HttpFoundation", + "source": { + "type": "git", + "url": "https://github.com/symfony/HttpFoundation.git", + "reference": "56111fc8ba8bcad93d367532babecc6ce17f66ce" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/56111fc8ba8bcad93d367532babecc6ce17f66ce", + "reference": "56111fc8ba8bcad93d367532babecc6ce17f66ce", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "symfony/expression-language": "~2.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.5-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\HttpFoundation\\": "" + }, + "classmap": [ + "Symfony/Component/HttpFoundation/Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "Symfony HttpFoundation Component", + "homepage": "http://symfony.com", + "time": "2014-10-24 05:49:22" + }, + { + "name": "symfony/yaml", + "version": "v2.5.6", + "target-dir": "Symfony/Component/Yaml", + "source": { + "type": "git", + "url": "https://github.com/symfony/Yaml.git", + "reference": "2d9f527449cabfa8543dd7fa3a466d6ae83d6726" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/2d9f527449cabfa8543dd7fa3a466d6ae83d6726", + "reference": "2d9f527449cabfa8543dd7fa3a466d6ae83d6726", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.5-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Yaml\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "Symfony Yaml Component", + "homepage": "http://symfony.com", + "time": "2014-10-01 05:50:18" + }, + { + "name": "twig/twig", + "version": "v1.16.2", + "source": { + "type": "git", + "url": "https://github.com/fabpot/Twig.git", + "reference": "42f758d9fe2146d1f0470604fc05ee43580873fc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/fabpot/Twig/zipball/42f758d9fe2146d1f0470604fc05ee43580873fc", + "reference": "42f758d9fe2146d1f0470604fc05ee43580873fc", + "shasum": "" + }, + "require": { + "php": ">=5.2.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.16-dev" + } + }, + "autoload": { + "psr-0": { + "Twig_": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Armin Ronacher", + "email": "armin.ronacher@active-4.com", + "role": "Project Founder" + }, + { + "name": "Twig Team", + "homepage": "https://github.com/fabpot/Twig/graphs/contributors", + "role": "Contributors" + } + ], + "description": "Twig, the flexible, fast, and secure template language for PHP", + "homepage": "http://twig.sensiolabs.org", + "keywords": [ + "templating" + ], + "time": "2014-10-17 12:53:44" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "platform": [], + "platform-dev": [] +} diff --git a/index.php b/index.php new file mode 100755 index 0000000..64e36d5 --- /dev/null +++ b/index.php @@ -0,0 +1,38 @@ +get('/', [$indexController, 'indexAction']); +$router->get('/tim', [$TimController, 'getTimsAction']); +$router->get('/tim/{timId}', [$TimController, 'getTimAction']); + +$dispatcher = new Phroute\Dispatcher($router); +try { + $response = $dispatcher->dispatch($request->getMethod(), parse_url($request->getPathInfo(), PHP_URL_PATH)); +} catch (Phroute\Exception\HttpRouteNotFoundException $e) { + $response = new Response($twig->render('error404.html.twig')); +} catch (Phroute\Exception\HttpMethodNotAllowedException $e) { + $response = new Response(sprintf('

Error 405:

Url was matched but method "%s" is not allowed', $e)); +} + +$response->send();*/ +$request = Request::createFromGlobals(); +$kernel = new MvcKernel(); +$response = $kernel->handle($request); +$response->send(); diff --git a/src/mvc/Controller/IndexController.php b/src/mvc/Controller/IndexController.php new file mode 100644 index 0000000..c30e4f3 --- /dev/null +++ b/src/mvc/Controller/IndexController.php @@ -0,0 +1,22 @@ +twig = $twig; + } + public function indexAction() + { + return new Response($this->twig->render('index.html.twig')); + } + public function errorAction() + { + return new Response($this->twig->render('error404.html.twig')); + } +} diff --git a/src/mvc/Controller/TimController.php b/src/mvc/Controller/TimController.php new file mode 100644 index 0000000..1f2cc29 --- /dev/null +++ b/src/mvc/Controller/TimController.php @@ -0,0 +1,75 @@ +twig = $twig; + } + /** + * @return Response + */ + public function getTimsAction() + { + return new Response($this->twig->render('tims.html.twig')); + } + public function getErrorAction() + { + return new Response($this->twig->render('error404.html.twig')); + } + /** + * @param string $id + * @return Response + */ + public function getTimAction($timId) + { + switch ($timId) { + case 'barsa': + $Barcelona = new Barcelona('Luis Enrique', 'Camp Nou', 'Xavier '); + echo $Barcelona->show(); + break; + case 'real': + $RealMadrid = new RealMadrid('Carlo Ancelotti', 'Santiago Bernabeu', 'Casillas'); + echo $RealMadrid->show(); + + echo ' Champions League - ' . $RealMadrid->LC(); + break; + default: + return new Response(sprintf('

Error:

Method not found for tim "%s"

', $timId)); + } + + return new Response($this->twig->render('tim.html.twig', array('show' => $timId)) . '
' . $timId); + } + /** + * @param string $id + * @return Response + */ + public function putArticleAction($id) + { + return new Response($this->twig->render('article.html.twig', ['method' => 'Put', 'articleId' => $id])); + } + /** + * @param string $id + * @return Response + */ + public function postArticleAction($id) + { + return new Response($this->twig->render('article.html.twig', ['method' => 'Post', 'articleId' => $id])); + } + /** + * @param string $id + * @return Response + */ + public function deleteArticleAction($id) + { + return new Response($this->twig->render('article.html.twig', ['method' => 'Delete', 'articleId' => $id])); + } +} diff --git a/src/mvc/Kernel.php b/src/mvc/Kernel.php new file mode 100644 index 0000000..78db66b --- /dev/null +++ b/src/mvc/Kernel.php @@ -0,0 +1,49 @@ +handleRoutes($this->getRoutes()); + $dispatcher = new Dispatcher($router); + try { + $response = $dispatcher->dispatch($request->getMethod(), parse_url($request->getPathInfo(), PHP_URL_PATH)); + } catch (\Phroute\Exception\HttpRouteNotFoundException $e) { + + $response = new Response($this->getTemplateHandler()->render('error404.html.twig')); + } catch (\Phroute\Exception\HttpMethodNotAllowedException $e) { + $response = new Response(sprintf('

Error 405:

Url was matched but method "%s" is not allowed', $e)); + } + return $response; + } + protected function handleRoutes(array $routes) + { + $controllers = $this->getControllers($routes); + $router = new RouteCollector(); + foreach ($routes as $routeDefinition) { + list($controller, $method) = explode(':', $routeDefinition[2]); + $router->{strtolower($routeDefinition[0])}($routeDefinition[1], [$controllers[$controller],$method]); + } + return $router; + } + protected function getControllers($routes) + { + $controllers = array(); + foreach ($routes as $routeDefinition) { + $controllerMethod = array_pop($routeDefinition); + list($controller, $method) = explode(':', $controllerMethod); + $controllers[$controller] = new $controller($this->getTemplateHandler()); + } + return $controllers; + } +} + diff --git a/src/mvc/KernelInterface.php b/src/mvc/KernelInterface.php new file mode 100644 index 0000000..7c0475f --- /dev/null +++ b/src/mvc/KernelInterface.php @@ -0,0 +1,12 @@ +setTrainer($trainer); + $this->setStadium($stadium); + $this->setCaptain($captain); + } + + abstract public function show(); + + /*================Set Values==================*/ + public function setTrainer($trainer) + { + $this->trainer = $trainer; + } + public function setStadium($stadium) + { + $this->stadium = $stadium; + } + public function setCaptain($captain) + { + $this->captain = $captain; + } + /*================Get Values===================*/ + public function getTrainer() + { + return $this->trainer; + } + public function getStadium() + { + return $this->stadium; + } + public function getCaptain() + { + return $this->captain; + } + +} diff --git a/src/mvc/Models/Article.php b/src/mvc/Models/Article.php new file mode 100644 index 0000000..3fff218 --- /dev/null +++ b/src/mvc/Models/Article.php @@ -0,0 +1,18 @@ +title = $title; + } + + public function getTitle() + { + return $this->title; + } +} diff --git a/src/mvc/Models/Barcelona.php b/src/mvc/Models/Barcelona.php new file mode 100644 index 0000000..5801e44 --- /dev/null +++ b/src/mvc/Models/Barcelona.php @@ -0,0 +1,22 @@ +getTrainer(), $this->getStadium(), $this->getCaptain()); + } + +} diff --git a/src/mvc/Models/LCInterface.php b/src/mvc/Models/LCInterface.php new file mode 100644 index 0000000..619d892 --- /dev/null +++ b/src/mvc/Models/LCInterface.php @@ -0,0 +1,13 @@ +getTrainer(), $this->getStadium(), $this->getCaptain()); + } + public function LC() + { + return "Chempion"; + } + +} diff --git a/src/mvc/MvcKernel.php b/src/mvc/MvcKernel.php new file mode 100644 index 0000000..a8cc76c --- /dev/null +++ b/src/mvc/MvcKernel.php @@ -0,0 +1,25 @@ +