PHP code example of junker / yaml-route-service-provider

1. Go to this page and download the library: Download junker/yaml-route-service-provider 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/ */

    

junker / yaml-route-service-provider example snippets


use Junker\Silex\Provider\YamlRouteServiceProvider;

$app->register(new YamlRouteServiceProvider('routes.yml'));

# or

$app->register(new YamlRouteServiceProvider('routes.yml', ['cache_dir' => '/tmp/routes_cache']));


# Acme\Controller\ArticlesController.php

use Silex\Application;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

namespace Acme\Controller;

class ArticlesController
{
	public function indexAction(Request $request, Application $app)
	{
		...

		return new Response($articles);
	}

	public function viewAction(Request $request, Application $app, $slug)
	{
		...

		return new Response($article);
	}
}