開発メモ

開発用のメモです。

外部アプリ化 + Twig 利用

TestApp/Application.php

<?php

namespace TestApp;

    class Application extends \Silex\Application {

        public function __construct( ) {
            parent::__construct( );

            // twig 対応 start
            $this->register( new \Silex\Provider\TwigServiceProvider( ), array( 'twig.path' => array( __DIR__ . '/Templates' ), ) );
            // twig 対応 end

            $this->mount( '', new Controller\Provider\HomeControllerProvider( ) );

        }

    }

TestApp/Controller/HomeController.php

<?php

namespace TestApp\Controller;

    use TestApp\Application;

    class HomeController {
        public function index( Application $app ) {
            return $app[ 'twig' ]->render( 'index.twig', array( ) );
        }

    }
Twitter: @asahina_alice