Skip to content

yceruto/symfony-onefile

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Symfony One File Challenge

<?php

require_once __DIR__.'/vendor/autoload.php';

use Symfony\Bundle\FrameworkBundle\Console\Application as ConsoleApplication;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Runtime\SymfonyRuntime;

class SymfonyOneFileApp extends Kernel
{
    use MicroKernelTrait;

    #[Route('/{name}', methods: 'GET')]
    public function __invoke(string $name = 'World'): Response
    {
        return new Response("Hello $name!");
    }
}

$app = new SymfonyOneFileApp('dev', true);

new SymfonyRuntime()
    ->getRunner(\PHP_SAPI === 'cli' ? new ConsoleApplication($app) : $app)
    ->run();

Use the same app.php as console and web application entry point.

php app.php cache:clear

or using the Symfony CLI server:

symfony serve

LICENSE

This software is published under the MIT License.

About

Symfony One File Challange

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages