Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

first commit

  • Loading branch information...
commit bed40531fd221828f121ae5b4cdb82c9be1001a2 1 parent df012e4
@francescoagati authored
View
74 cache/.php
@@ -0,0 +1,74 @@
+<?php
+
+use Symfony\Component\DependencyInjection\ContainerInterface;
+use Symfony\Component\DependencyInjection\Container;
+use Symfony\Component\DependencyInjection\Exception\InactiveScopeException;
+use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
+use Symfony\Component\DependencyInjection\Exception\LogicException;
+use Symfony\Component\DependencyInjection\Exception\RuntimeException;
+use Symfony\Component\DependencyInjection\Reference;
+use Symfony\Component\DependencyInjection\Parameter;
+use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
+
+/**
+ * ProjectServiceContainer
+ *
+ * This class has been auto-generated
+ * by the Symfony Dependency Injection Component.
+ */
+class ProjectServiceContainer extends Container
+{
+ /**
+ * Constructor.
+ */
+ public function __construct()
+ {
+ $this->services =
+ $this->scopedServices =
+ $this->scopeStacks = array();
+
+ $this->set('service_container', $this);
+
+ $this->scopes = array();
+ $this->scopeChildren = array();
+ }
+
+ /**
+ * Gets the 'app' service.
+ *
+ * This service is shared.
+ * This method always returns the same instance of the service.
+ *
+ * @return App A App instance.
+ */
+ protected function getAppService()
+ {
+ return $this->services['app'] = new \App($this->get('proxy'));
+ }
+
+ /**
+ * Gets the 'curl' service.
+ *
+ * This service is shared.
+ * This method always returns the same instance of the service.
+ *
+ * @return Curl A Curl instance.
+ */
+ protected function getCurlService()
+ {
+ return $this->services['curl'] = new \Curl();
+ }
+
+ /**
+ * Gets the 'proxy' service.
+ *
+ * This service is shared.
+ * This method always returns the same instance of the service.
+ *
+ * @return Proxy A Proxy instance.
+ */
+ protected function getProxyService()
+ {
+ return $this->services['proxy'] = new \Proxy($this->get('curl'));
+ }
+}
View
15 composer.json
@@ -0,0 +1,15 @@
+{
+ "require": {
+ "monolog/monolog": "1.2.*",
+ "symfony/dependency-injection": "dev-master",
+ "symfony/yaml": "dev-master",
+ "symfony/config": "dev-master",
+ "resty/resty": "dev-master",
+ "twig/twig": "dev-faster-exceptions"
+ },
+ "autoload":{
+ "psr-0":{
+ "":"lib/"
+ }
+ }
+}
View
315 composer.lock
@@ -0,0 +1,315 @@
+{
+ "hash": "4f921c5f26c2fbbc7265d37972706ba2",
+ "packages": [
+ {
+ "name": "monolog/monolog",
+ "version": "1.2.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/Seldaek/monolog",
+ "reference": "1.2.1"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://github.com/Seldaek/monolog/zipball/1.2.1",
+ "reference": "1.2.1",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.0"
+ },
+ "require-dev": {
+ "mlehner/gelf-php": "1.0.*"
+ },
+ "suggest": {
+ "mlehner/gelf-php": "Allow sending log messages to a GrayLog2 server",
+ "ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)",
+ "ext-mongo": "Allow sending log messages to a MongoDB server"
+ },
+ "time": "2012-08-29 04:53:20",
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.3.x-dev"
+ }
+ },
+ "installation-source": "dist",
+ "autoload": {
+ "psr-0": {
+ "Monolog": "src/"
+ }
+ },
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Jordi Boggiano",
+ "email": "j.boggiano@seld.be",
+ "homepage": "http://seld.be",
+ "role": "Developer"
+ }
+ ],
+ "description": "Logging for PHP 5.3",
+ "homepage": "http://github.com/Seldaek/monolog",
+ "keywords": [
+ "log",
+ "logging"
+ ]
+ },
+ {
+ "name": "resty/resty",
+ "version": "dev-master",
+ "source": {
+ "type": "git",
+ "url": "git://github.com/fictivekin/Resty.php.git",
+ "reference": "51a9bcb36791813a7def1370674bc8717e776120"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://github.com/fictivekin/Resty.php/zipball/51a9bcb36791813a7def1370674bc8717e776120",
+ "reference": "51a9bcb36791813a7def1370674bc8717e776120",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.0"
+ },
+ "time": "1347544012",
+ "type": "library",
+ "installation-source": "source",
+ "autoload": {
+ "psr-0": {
+ "Resty": ""
+ }
+ },
+ "license": [
+ "Apache 2.0"
+ ],
+ "authors": [
+ {
+ "name": "Ed Finkler",
+ "email": "ed@fictivekin.com",
+ "homepage": "http://fictivekin.com"
+ }
+ ],
+ "description": "A simple PHP library for doing RESTful HTTP stuff. Does not require the curl extension",
+ "homepage": "https://github.com/fictivekin/resty.php",
+ "keywords": [
+ "http",
+ "rest",
+ "client",
+ "restful"
+ ]
+ },
+ {
+ "name": "symfony/config",
+ "version": "dev-master",
+ "target-dir": "Symfony/Component/Config",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/Config",
+ "reference": "dbfadc6995574df68ad9b6c7e56a68b4bd9d0fa3"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://github.com/symfony/Config/zipball/dbfadc6995574df68ad9b6c7e56a68b4bd9d0fa3",
+ "reference": "dbfadc6995574df68ad9b6c7e56a68b4bd9d0fa3",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3"
+ },
+ "time": "1349553479",
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.2-dev"
+ }
+ },
+ "installation-source": "source",
+ "autoload": {
+ "psr-0": {
+ "Symfony\\Component\\Config\\": ""
+ }
+ },
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "http://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony Config Component",
+ "homepage": "http://symfony.com"
+ },
+ {
+ "name": "symfony/dependency-injection",
+ "version": "dev-master",
+ "target-dir": "Symfony/Component/DependencyInjection",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/DependencyInjection",
+ "reference": "1a3657352a94cac0f2009610fdee95313427f7c1"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://github.com/symfony/DependencyInjection/zipball/1a3657352a94cac0f2009610fdee95313427f7c1",
+ "reference": "1a3657352a94cac0f2009610fdee95313427f7c1",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3"
+ },
+ "require-dev": {
+ "symfony/yaml": "2.2.*",
+ "symfony/config": "2.2.*"
+ },
+ "suggest": {
+ "symfony/yaml": "2.2.*",
+ "symfony/config": "2.2.*"
+ },
+ "time": "1350594979",
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.2-dev"
+ }
+ },
+ "installation-source": "source",
+ "autoload": {
+ "psr-0": {
+ "Symfony\\Component\\DependencyInjection\\": ""
+ }
+ },
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "http://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony DependencyInjection Component",
+ "homepage": "http://symfony.com"
+ },
+ {
+ "name": "symfony/yaml",
+ "version": "dev-master",
+ "target-dir": "Symfony/Component/Yaml",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/Yaml",
+ "reference": "1f7ba14c4b263dbf701e25705b0b2175a850a784"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://github.com/symfony/Yaml/zipball/1f7ba14c4b263dbf701e25705b0b2175a850a784",
+ "reference": "1f7ba14c4b263dbf701e25705b0b2175a850a784",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3"
+ },
+ "time": "1349553479",
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.2-dev"
+ }
+ },
+ "installation-source": "source",
+ "autoload": {
+ "psr-0": {
+ "Symfony\\Component\\Yaml\\": ""
+ }
+ },
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "http://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony Yaml Component",
+ "homepage": "http://symfony.com"
+ },
+ {
+ "name": "twig/twig",
+ "version": "dev-faster-exceptions",
+ "source": {
+ "type": "git",
+ "url": "git://github.com/fabpot/Twig.git",
+ "reference": "2506be1794fb2fcad5b0a8183c32be1d14c4599a"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://github.com/fabpot/Twig/zipball/2506be1794fb2fcad5b0a8183c32be1d14c4599a",
+ "reference": "2506be1794fb2fcad5b0a8183c32be1d14c4599a",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.2.4"
+ },
+ "time": "1350650758",
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.11-dev"
+ }
+ },
+ "installation-source": "source",
+ "autoload": {
+ "psr-0": {
+ "Twig_": "lib/"
+ }
+ },
+ "license": [
+ "BSD-3"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Armin Ronacher",
+ "email": "armin.ronacher@active-4.com"
+ }
+ ],
+ "description": "Twig, the flexible, fast, and secure template language for PHP",
+ "homepage": "http://twig.sensiolabs.org",
+ "keywords": [
+ "templating"
+ ]
+ }
+ ],
+ "packages-dev": null,
+ "aliases": [
+
+ ],
+ "minimum-stability": "stable",
+ "stability-flags": {
+ "symfony/dependency-injection": 20,
+ "symfony/yaml": 20,
+ "symfony/config": 20,
+ "resty/resty": 20,
+ "twig/twig": 20
+ }
+}
View
71 main.php
@@ -0,0 +1,71 @@
+<?php
+
+use Monolog\Logger;
+use Monolog\Handler\StreamHandler;
+
+class App
+{
+ private $proxy;
+
+ public function __construct(Monolog\Logger $logger, Resty $rest, Twig_Environment $render)
+ {
+ echo "App::__construct\n";
+ $this->proxy = $proxy;
+ $this->logger= $logger;
+ $this->rest=$rest;
+ $this->render=$render;
+ }
+
+ public function hello()
+ {
+ $this->logger->addWarning('Foo');
+ $this->logger->addError('Bar');
+
+ return $this->render->render('prova.twig', array('name' => 'Fabien'));;
+ }
+}
+
+
+
+
+
+include __DIR__ . "/vendor/autoload.php";
+
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\DependencyInjection\Reference;
+use Symfony\Component\Config\FileLocator;
+use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
+use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
+
+
+
+function getContainer($yaml_file) {
+
+ $file = __DIR__ .'/cache/'.(split("\.",$yaml_file)[0]).'.php';
+ if (file_exists($file)) {
+ require_once $file;
+ $container = new ProjectServiceContainer();
+ } else {
+
+ $container = new ContainerBuilder();
+ $loader = new YamlFileLoader($container, new FileLocator(__DIR__));
+ $loader->load($yaml_file);
+ $container->compile();
+ $dumper = new PhpDumper($container);
+ echo $file;
+ file_put_contents($file, $dumper->dump());
+
+ }
+ return $container;
+}
+
+
+
+
+
+
+echo getContainer("services.yml")->get('app')->hello();
+
+
+
+
View
32 services.yml
@@ -0,0 +1,32 @@
+services:
+ app:
+ class: App
+ arguments: [@Logger,@Rest,@Twig_enviroment]
+ proxy:
+ class: Proxy
+ arguments: [@Curl]
+ curl:
+ class: Curl
+ logger:
+ class: Monolog\Logger
+ arguments: ["pippa"]
+ calls:
+ - [pushHandler, [@stream_handler]]
+ stream_handler:
+ class: Monolog\Handler\StreamHandler
+ arguments: ["pippa.log",Logger::WARNING]
+ rest:
+ class: Resty
+ calls:
+ - [setBaseURL, ['https://gimmebar.com/api/v1']]
+ twig_loader_string:
+ class: Twig_Loader_String
+ twig_loader_filesystem:
+ class: Twig_Loader_Filesystem
+ arguments: ['templates']
+ twig_enviroment:
+ class: Twig_Environment
+ arguments: [@Twig_loader_filesystem]
+
+
+
View
1  templates/prova.twig
@@ -0,0 +1 @@
+Hello {{ name }}!
Please sign in to comment.
Something went wrong with that request. Please try again.