PHP code example of symplify / symfony-static-dumper
1. Go to this page and download the library: Download symplify/symfony-static-dumper 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/ */
symplify / symfony-static-dumper example snippets
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\SymfonyStaticDumper\ValueObject\SymfonyStaticDumperConfig;
return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->import(SymfonyStaticDumperConfig::FILE_PATH);
};
namespace TomasVotruba\SymfonyStaticDump\ControllerWithDataProvider;
use Symplify\SymfonyStaticDumper\Contract\ControllerWithDataProviderInterface;
use TomasVotruba\Blog\Controller\PostController;
use TomasVotruba\Blog\Repository\PostRepository;
final class PostControllerWithDataProvider implements ControllerWithDataProviderInterface
{
private PostRepository $postRepository;
public function __construct(PostRepository $postRepository)
{
$this->postRepository = $postRepository;
}
public function getControllerClass(): string
{
return PostController::class;
}
public function getControllerMethod(): string
{
return '__invoke';
}
/**
* @return string[]
*/
public function getArguments(): array
{
$slugs = [];
foreach ($this->postRepository->getPosts() as $post) {
$slugs[] = $post->getSlug();
}
return $slugs;
}
}
namespace TomasVotruba\Blog\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use TomasVotruba\Blog\Repository\PostRepository;
use TomasVotruba\Blog\ValueObject\Post;
final class PostController extends AbstractController
{
private PostRepository $postRepository;
public function __construct(PostRepository $postRepository)
{
$this->postRepository = $postRepository;
}
/**
* @Route(path="/blog/{slug}", name="post_detail",
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.