PHP code example of packfire / fuelblade

1. Go to this page and download the library: Download packfire/fuelblade 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/ */

    

packfire / fuelblade example snippets



    class ConsoleOutput
    {
        public function write($message)
        {
            echo $message;
        }        
    }

    class TaskManager
    {
        protected $output;

        public function __construct()
        {
            $this->output = new ConsoleOutput();
        }
    }

    class Application
    {
        public function run()
        {
            $manager = new TaskManager();
            $manager->run();                  
        }
    }



    interface OutputInterface
    {
        public function write($message);
    }

    class ConsoleOutput implements OutputInterface
    {
        public function write($message)
        {
            echo $message;
        }        
    }

    class FileOutput implements OutputInterface
    {
        public function write($message)
        {
            // write to file
        }        
    }

    class TaskManager
    {
        protected $output;

        public function __construct(OutputInterface $output)
        {
            $this->output = $output;
        }

    }

    class Application
    {
        public function run()
        {
            $ioc = new \Packfire\FuelBlade\Container();
            $ioc['manager'] = $this->share(
                function ($ioc) {
                    return new TaskManager($ioc['output']);
                }
            );
            $ioc['output'] = $this->share(new FileOutput());
            $ioc['manager']->run();                    
        }
    }