PHP code example of spiffy / spiffy-config

1. Go to this page and download the library: Download spiffy/spiffy-config library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

spiffy / spiffy-config example snippets


use SpiffyConfig\Annotation as Config;

             array(
                'my' => array(
                    'nested' => array(
                        // service configuration would go here
                    )
                )
             )
             

namespace Application\Service;

use SpiffyConfig\Annotation\Service;

/**
 * This annotation will set the Mailer service using the service_manager key
 * under the service name "Application\Service\Mailer". I could specify a name
 * if I don't want to use the FQCN.
 *
 * @Service\Invokable
 */
class Mailer implements ServiceLocatorAwareInterface
{
    // ... implementation ...
}

namespace Application\Service;

use SpiffyConfig\Annotation\Service;

/**
 * This annotation will set the Mailer service using the service_manager key
 * under the service name "mailer" and being built from the "Application\Service\MailerFactory"
 * factory.
 *
 * @Service\Factory("Application\Service\MailerFactory", name="mailer")
 */
class Mailer implements ServiceLocatorAwareInterface
{
    // ... implementation ...
}



namespace Application\Controller;

use SpiffyConfig\Annotation\Route;
use Zend\Mvc\Controller\AbstractActionController;

/**
 * @Route\Literal("/", name="home", action="index")
 */
class IndexController extends AbstractActionController
{
    // This annotation is set on the controller level.
    public function indexAction()
    {
        // ...
    }

    /**
     * @Route\Segment("/foo/:id", name="foo", options={"constraints":{"id":"\d+"}}")
     */
    public function fooAction()
    {
        // ...
    }

    /**
     * @Route\Literal("/bar", name="bar", parent="foo")
     */
    public function barAction()
    {
        // ...
    }
}

namespace Application\Controller;

use SpiffyConfig\Annotation\Controller;
use SpiffyConfig\Annotation\Route;
use Zend\Mvc\Controller\AbstractActionController;

/**
 * @Controller\RouteParent("home", action="index")
 */
class IndexController extends AbstractActionController
{
    /**
     * @Route\Literal("/")
     */
    public function indexAction()
    {
        // ...
    }

    /**
     * Resolves to /foo and is named home/foo.
     *
     * @Route\Literal("foo", name="foo")
     */
    public function fooAction()
    {
        // ...
    }
}