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..8aa6e5e --- /dev/null +++ b/.htaccess @@ -0,0 +1,4 @@ +RewriteEngine on +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +RewriteRule ^(.*)$ /src/mvc/index.php?route=$1 [L,QSA] diff --git a/app/views/article.html.twig b/app/views/article.html.twig new file mode 100644 index 0000000..8394e93 --- /dev/null +++ b/app/views/article.html.twig @@ -0,0 +1 @@ +{{ method|upper }} Article with "{{ articleId }}" id action \ No newline at end of file diff --git a/app/views/index.html.twig b/app/views/index.html.twig new file mode 100644 index 0000000..6769dd6 --- /dev/null +++ b/app/views/index.html.twig @@ -0,0 +1 @@ +Hello world! \ No newline at end of file diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..5d7892d --- /dev/null +++ b/composer.json @@ -0,0 +1,10 @@ +{ + "autoload": { + "psr-0": {"mvc": "src/"} + }, + "require": { + "symfony/http-foundation": "2.5.6", + "twig/twig": "1.16.2", + "phroute/phroute": "1.4.1" + } +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..0973726 --- /dev/null +++ b/composer.lock @@ -0,0 +1,174 @@ +{ + "_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": "2d380187c1420c8d316a7d61dbca04e7", + "packages": [ + { + "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": "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": "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 100644 index 0000000..0856de1 --- /dev/null +++ b/index.php @@ -0,0 +1,41 @@ +get('/', [$indexController,'indexAction']); + +$router->get('/articles/{id}', [$articleController,'getArticleAction']); +$router->put('/articles/{id}', [$articleController,'getArticleAction']); +$router->post('/articles/{id}', [$articleController,'getArticleAction']); +$router->delete('/articles/{id}', [$articleController,'getArticleAction']); +$router->get('/articles', [$articleController,'getArticlesAction']); + +$dispatcher = new Dispatcher($router); +$response = $dispatcher->dispatch($request->getMethod(), parse_url($request->getPathInfo(), PHP_URL_PATH)); + +$response->send(); + + + diff --git a/src/mvc/Controller/ArticleController.php b/src/mvc/Controller/ArticleController.php new file mode 100644 index 0000000..ecab1d1 --- /dev/null +++ b/src/mvc/Controller/ArticleController.php @@ -0,0 +1,54 @@ +twig = $twig; + } + /** + * @return Response + */ + public function getArticlesAction() + { + return new Response('So many articles here'); + } + /** + * @param string $id + * @return Response + */ + public function getArticleAction($id) + { + return new Response($this->twig->render('article.html.twig', ['method' => 'Get', 'articleId' => $id])); + } + /** + * @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])); + } +} \ No newline at end of file diff --git a/src/mvc/Controller/IndexController.php b/src/mvc/Controller/IndexController.php new file mode 100644 index 0000000..b2f9d08 --- /dev/null +++ b/src/mvc/Controller/IndexController.php @@ -0,0 +1,16 @@ +show(); + return $b; + + } + public function getRealParametrs() + { + $Real = new RealMadrid('Carlo Ancelotti','Santiago Bernabeu','Casillas'); + + $r['show'] = $Real->show(); + return $r; + + } +} \ No newline at end of file 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/Views/barcelonaView.php b/src/mvc/Views/barcelonaView.php new file mode 100644 index 0000000..ced30fb --- /dev/null +++ b/src/mvc/Views/barcelonaView.php @@ -0,0 +1,11 @@ + +
+ + + + +