PHP code example of ac / slimfra
1. Go to this page and download the library: Download ac/slimfra 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/ */
ac / slimfra example snippets
$service = $this['some.service.name'];
$config = $this['some.value'];
class MyController extends Slimfra\Controller
{
public function helloWorldAction()
{
$service = $this->app['some.service'];
//...do whatever
return 'Hello World!';
}
}
$app = new Slimfra\Application();
$app->get('/hello-world', 'MyController::helloWorldAction');
$app->run();
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class HelloWorldCommand extends Slimfra\Command
{
protected function configure()
{
$this->setName('hello-world');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$service = $this->app['some.service'];
//... do whatever
$output->writeln('Hello World!');
}
}
$app = new Slimfra\Console(new Slimfra\Application());
$app->add(new HelloWorldCommand());
$app->run();