PHP code example of angedelamort / php-sun-framework

1. Go to this page and download the library: Download angedelamort/php-sun-framework 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/ */

    

angedelamort / php-sun-framework example snippets


    $options = new SunAppConfig()->activateDebugBar(__DIR__ . '/generated', '/generated')->(...)
    $app = new SunApp($options);
    

    // Normal monolog stuff
    $logger = new SunLogger('name');
    $logger->info('Hello here!');
    
    // To appear in the 'Message' section
    $logger->message('Should appear in the message section');
    
`
--- index.php ---

use sunframework\SunApp;

on(Slim\App $app) {
        $app->get('/', function() {
            return "Hello World";
        });
    }
]);
$app->run()

`
--- public/index.php ---


use sunframework\SunApp;

__) . '/locale',
    'view.templates' => dirname(__DIR__) . '/templates',
    'routes.controllers' => 'sample\controllers'
]);
$app->run();
`
--- app/controllers/HomeController.php ---
namespace sample\controllers;

use sunframework\route\IRoutable;

class HomeController implements IRoutable {
    public function registerRoute($app) {
        $app->get('/', function($request, $response, $args) {
            return $this->view->render($response, 'test.twig', [
                'user' => 'John Doe'
            ]);
        });
    }
}

class FinalState extends BaseState {
    public function __construct() {
        parent::__construct();
        
        $mySimpleTransition = new Transition(NextState::name());
        $this->addTransition($mySimpleTransition);
    }
}

$t = new Transition(NextState::name(), [$this, 'setLetter']);
$t->addCondition(function (StateMachineContext $context) {
    $val = intval($context->getRequest()->getParsedBodyParam('val'));
    return $val < 10;
});