PHP code example of dotkernel / dot-annotated-services
1. Go to this page and download the library: Download dotkernel/dot-annotated-services 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/ */
dotkernel / dot-annotated-services example snippets
use Doctrine\ORM\EntityRepository;
use Dot\AnnotatedServices\Annotation\Entity;
/**
* @Entity(name="App\Entity\Example")
*/
class ExampleRepository extends EntityRepository
{
}
use Dot\AnnotatedServices\Annotation\Service;
/*
* @Service
*/
class ServiceClass
{
// configure injections as described in the previous section
}
return [
'annotations_cache_dir' => __DIR__ . '/../../data/cache/annotations',
'dependencies' => [
'factories' => [
// used by dot-annotated-services to cache annotations
// needs to return a cache instance from Doctrine\Common\Cache
AbstractAnnotatedFactory::CACHE_SERVICE => AnnotationsCacheFactory::class,
]
],
];
namespace Frontend\App\Factory;
use Doctrine\Common\Cache\FilesystemCache;
use Psr\Container\ContainerInterface;
class AnnotationsCacheFactory
{
public function __invoke(ContainerInterface $container)
{
//change this to suite your caching needs
return new FilesystemCache($container->get('config')['annotations_cache_dir']);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.