I tring to get an argument in my services.yaml for my ImageManager.php but it's not working and I can not solve this error.
here is the mistake :
Type error: Too few arguments to function App\Manager\ImageManager::__construct(), 0 passed in C:\wamp64\www\SymfonyAPI\var\cache\dev\ContainerZxFSS5S\getImageManagerService.php on line 14 and exactly 1 expected
services.yaml
parameters:
images_directory: '%kernel.project_dir%/public/uploads/images/'
...
services:
_defaults:
autowire: false
autoconfigure: false
public: true
App\Manager\ImageManager:
arguments:
$targetDir: '%images_directory%'
if for autowire & autoconfigure I put true I have this error :
RuntimeException Cannot autowire service "App\Manager\ImageManager": argument "$targetDir" of method "__construct()" has type "App\Manager\targetDir" but this class was not found.
ImageManager.php
private $targetDir;
public function __construct(targetDir $targetDir)
{
$this->targetDir = $targetDir;
}
Full services.yml
parameters:
liip_imagine.mozjpeg.binary: /mozjpeg/cjpeg.exe
images_directory: '%kernel.project_dir%/public/uploads/images/'
mozjpg_directory: '%kernel.project_dir%/mozjpg'
locale: 'en'
services:
_defaults:
autowire: false
autoconfigure: false
public: true
App\Manager\ImageManager:
arguments:
$targetDir: '%images_directory%'
App\EventListener\ImageUploadListener:
tags:
- { name: doctrine.event_listener, event: prePersist }
- { name: doctrine.event_listener, event: preUpdate }
App\:
resource: '../src/*'
exclude: '../src/{Entity,Migrations,Tests,Kernel.php}'
App\Controller\:
resource: '../src/Controller'
tags: ['controller.service_arguments']
app.post_processor.my_custom_post_processor:
class: '%kernel.project_dir%/src/Controller/ImageController.php'
tags:
- { name: 'liip_imagine.filter.post_processor', post_processor: 'mozjpeg' }