php-symfonyHow to create a backend with PHP Symfony?
Creating a backend with PHP Symfony is easy and straightforward.
Install the Symfony framework:
$ composer create-project symfony/website-skeleton my-project
Create a controller:
<?php
namespace App\Controller;
use Symfony\Component\HttpFoundation\Response;
class DefaultController
{
public function index()
{
return new Response('Hello World!');
}
}
Create a route:
# config/routes.yaml
index:
path: /
controller: App\Controller\DefaultController::index
Start the server:
$ cd my-project
$ symfony server:start
Visit the page:
http://localhost:8000
You should now see the "Hello World!" message.
Helpful links
More of Php Symfony
- How to use dependency injection in Symfony with PHP?
- How to install Symfony on Windows?
- How to create tests in Symfony with PHP?
- How to upload a file in PHP Symfony?
- How to create a model in PHP Symfony?
- How to use the messenger component in PHP Symfony?
- How to generate a model in PHP Symfony?
- What are the required PHP Symfony extensions?
- How to integrate Vue.js with PHP Symfony?
See more codes...