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 create a model in PHP Symfony?
- How to check PHP Symfony version?
- How to do validation in PHP Symfony?
- How to do testing with PHP Symfony?
- How to get request parameters in PHP Symfony?
- How to integrate Vue.js with PHP Symfony?
- How to manage sessions in Symfony with PHP?
- How to use Prometheus with PHP Symfony?
- How to upload a file in PHP Symfony?
- How to install Symfony on Windows?
See more codes...