PHP code example of fwk / core

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

    

fwk / core example snippets


$app->register('Hello', ProxyFactory::factory(function() { /* ... */ })); // CallableActionProxy
$app->register('Hello', ProxyFactory::factory('+file.php')); // IncludeActionProxy
$app->register('Hello', ProxyFactory::factory('HelloWorld\\HelloController:show')); // ControllerActionProxy
$app->register('Hello', ProxyFactory::factory('@service')); // ServiceActionProxy
$app->register('Hello', ProxyFactory::factory('@service:method')); // ServiceControllerActionProxy
file.php
file.php
 php

namespace HelloWorld;

// we're index.php in the 'public' http folder (the doc_root)
me = null) {
    return 'Hello '. (!empty($name) ? $name : 'World');
};

// the above is a shortcut to this:
$app->register(
    'Hello', 
    new \Fwk\Core\Action\CallableActionProxy(
        function($name = null) {
            return 'Hello '. (!empty($name) ? $name : 'World');
        }
    )
);

// The  is needed to respond to / (or index.php)
$app->setDefaultAction('Hello');

// execute
$response = $app->run();
if ($response instanceof \Symfony\Component\HttpFoundation\Response) {
    $response->send();
} else {
    echo $response;
}