I'd like use Symfony2 bundle SRIORestUploadBundle to handle the upload of a file through an API but after setting up the basic configuration, it still get the following error: ServiceNotFoundException in CheckExceptionOnInvalidReferenceBehaviorPass.php line 58:
The service "srio_rest_upload.storage.default" has a dependency on a non-existent service "gaufrette.uploads_filesyste".
it is a typo, missing "m" after gaufrette.uploads_filesyste
I appologies for the fact I didn't do the configuration well (copy past doesn't necessary work with YAML). In fact the follwing config doesn't generate error:
knp_gaufrette:
adapters:
local_uploads:
local:
directory: %kernel.root_dir%/../web/uploads
filesystems:
uploads:
adapter: local_uploads
srio_rest_upload:
storages:
default:
filesystem: gaufrette.uploads_filesystem
Related
I'm having autowiring issues within symfony since I have updated my Docker to the latest version.
I am not entirely sure of the causality here but certainly, my issues started appearing only after updating my docker. Since this was the case I obviously tried to revert back to a previous docker version but still had the same issues as on the new build. That's why I am doubtful of the causality.
I'm now on: Docker version 3.5.2 with Docker Engine v20.10.7
docker-engine config is the unchanged config:
{
"registry-mirrors": [],
"insecure-registries": [],
"debug": false,
"experimental": false,
"features": {
"buildkit": true
},
"builder": {
"gc": {
"enabled": true,
"defaultKeepStorage": "20GB"
}
}
}
when I started my first project I had an issue with the composer not reading my lib-folder. This was solved as described below but it might provide some more insight, context and things I have checked/done
At first my mind went to this Windows env variable. Alas, it was set so it was not the problem.
Secondly, my mind went to file ownership or file permissions but also not the problem. Everything in my containers was owned by root and had rwx permissions.
Thirdly I thought it might be because of the new WSL2 backend I had to install. Until the day of the update I had still been running on the Hyper-V backend. Luckily there is a setting in docker where you can switch off the use of WSL-2 and revert to Hyper-V but this was also not the solution to my problem.
My composer.json looked like this:
"autoload": {
"classmap": [
"scripts/composer/ScriptHandler.php",
"lib/",
...
],
"psr-4": {
...
}
},
Everything but (some) files of lib were present in my autoload_classmap.php
After fiddling about for too long I finally tried the following and suddenly my problems on my first project were gone
"autoload": {
"classmap": [
"scripts/composer/ScriptHandler.php",
"lib/*",
...
],
"psr-4": {
...
}
},
I still don't understand why the first one should not work. It has worked until this thursday since the infamous update.
Now on to the second project and I really can't figure out what's going on and I'm at a loss for words. My colleagues can't seem to figure out what's wrong either. This second project is something more recent so not loading a classmap anymore and everything follows PSR-4 standards.
This is the autoload part of the composer.json:
"autoload": {
"psr-4": {
"App\\": "src/",
"Project\\": "scripts/"
}
},
This is my services.yaml (These are just the standard symfony settings AFAIK):
services:
# default configuration for services in *this* file
_defaults:
autowire: true # Automatically injects dependencies in your services.
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
public: false # Allows optimizing the container by removing unused services; this also means
# fetching services directly from the container via $container->get() won't work.
# The best practice is to be explicit about your dependencies anyway.
# makes classes in src/ available to be used as services
# this creates a service per class whose id is the fully-qualified class name
App\:
resource: '../src/*'
exclude: '../src/{Entity,Migrations,Tests,Kernel.php}'
This is my docker PHP container:
php:
container_name: "${DOCKER_PROJECT_NAME}_php"
environment:
COLUMNS: 80
PHP_FPM_GROUP: wodby
PHP_FPM_USER: wodby
PHP_SENDMAIL_PATH: "/usr/sbin/sendmail -t -i -S mailhog:1025"
PHP_DEFAULT_CHARSET: 'utf-8'
PHP_DATE_TIMEZONE: 'UTC'
PHP_UPLOAD_MAX_FILESIZE: '10M'
PHP_POST_MAX_SIZE: '10M'
PHP_DISPLAY_ERRORS: 'On'
PHP_DISPLAY_STARTUP_ERRORS: 'On'
PHP_MAX_EXECUTION_TIME: '30000'
PHP_MAX_INPUT_TIME: '60'
PHP_MAX_INPUT_VARS: '2000'
PHP_ERROR_REPORTING: 'E_ALL'
PHP_LOG_ERRORS: 'On'
PHP_LOG_ERRORS_MAX_LEN: '0'
PHP_MEMORY_LIMIT: '512M'
PHP_SESSION_GC_MAXLIFETIME: '700000'
PHP_REALPATH_CACHE_SIZE: '4096K'
PHP_REALPATH_CACHE_TTL: '3600'
PHP_XHPROF: $PROFILING_ENABLED
env_file:
- .env
image: "wodby/php:7.4-dev-4.16.2"
volumes:
- "./:/var/www/html"
## For php profiler traces
- "files:/mnt/files"
On startup I am getting the following Runtime Exception:
Cannot autowire service "App\Form\Wizard\DaysOffType": argument "$daycareTransformer" of method "__construct()" references class "App\Form\DaycareTransformer" but no such service exists.
This class is not new, it's been in code for 2 years. It's in the right folder and the namespacing is correct. Also the src folder is included in the autoload_psr4.php.
The DaycareTransformer that "can't be found" is located in src/Form under the namespace App\Form as per psr4 namespace convention
<?php
namespace App\Form;
use App\Entity\Daycare;
use App\Service\DaycareService;
use Symfony\Component\Form\DataTransformerInterface;
use Symfony\Component\Form\Exception\TransformationFailedException;
class DaycareTransformer implements DataTransformerInterface
{
private $daycareService;
public function __construct(DaycareService $daycareService)
{
$this->daycareService = $daycareService;
}
...
}
There have not been any recent changes to this code. Not to the DaysOffType which has the DaycareTransformer injected and not to the DaycareTransformer.
I am the only person having these issues as I am the only one who runs Docker on a Windows machine. Production and QA environments are all up and running so there is no structural problem in the code.
It could be because the project running symphony in this case was locate at Windows partition (C: or D: or whatever inside your window) and not Linux distro.
If you are using WSL (most likely), you should always store Linux related project inside your distro (Ubuntu in my case, I store it it ~/...). You should not store Linux related project in /mnt/... when using WSL.
When I said "Linux related" I mean whatever project usually want to run on Linux environment, or using docker
Don't know if this could solve it for others because there could be a wide range of reason for this problem. But this is how I solve mine.
We've got the same problem on a Windows machine with Docker and Symfony 5.x.
We continued to work on this machine, but we changed our configuration.
For example, for your error I would use the following config.
Cannot autowire service "App\Form\Wizard\DaysOffType": argument "$daycareTransformer" of method "__construct()" references class "App\Form\DaycareTransformer" but no such service exists.
config/services.yml or config/services_dev.yml
services:
App\Form\DaycareTransformer: ~
We defined all the required classes from our errors and it solved our problem. But it solved problem only for one URL instead of all. You need to check each your routes or classes that use Symfony's autowire.
Unfortunately, the solution like declaration of resources didn't for us. We had to define all the required classes from our errors.
services:
App\DataTransformer\:
resource: '../src/DataTransformer/'
Don't redefined your classes that have already defined in your config, because it replaces your configuration and may make other errors.
You can do it in config/services.yml and commit it or you can use config/service_dev.yml and don't commit it if you haven't use this config before. In the second way you also can change .gitignore and add there the filename.
# Ignore changes for the file and don't track it.
config/services_dev.yml
WARNING! If you still have problems with it define all the required classes in services.yml instead of two or more config files.
We don't have this problem on Linux and MacOS machines.
When I enable the 'dev' mode in my Symfony 4 app (that is already online in a shared hosting service) it shows this message:
(1/1) ParameterNotFoundException
You have requested a non-existent parameter "locale".
in ParameterBag.php (line 100)
at ParameterBag->get('locale')
in EnvPlaceholderParameterBag.php (line 57)
at EnvPlaceholderParameterBag->get('locale')
in ParameterBag.php (line 216)
at ParameterBag->resolveString('%locale%', array('locale' => true))
in ParameterBag.php (line 187)
...
and does not allow to debug the app. My config/services.yml code is as default:
# Put parameters here that don't need to change on each machine where the app is deployed
# https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
locale: 'en'
services:
# default configuration for Services in *this* file
_defaults:
autowire: true # Automatically injects dependencies in your Services.
autoconfigure: true # Automatically registers your Services as commands, event subscribers, etc.
public: false # Allows optimizing the container by removing unused Services; this also means
# fetching Services directly from the container via $container->get() won't work.
# The best practice is to be explicit about your dependencies anyway.
...
Please, someone can help me to fix this error.
Had the same problem during the fresh symfony 4.3 + sonata admin bundle installation.
As a solution I added locale parameter:
// /config/services.yaml
parameters:
locale: 'en'
While I am not a Symphony expert the documentation appears to allow anything in the parameters section, but it does mention also defining the values in the .env.dist file as well for them to be used here.
http://symfony.com/doc/current/best_practices/configuration.html#canonical-parameters
When upgrading from symfony 4.2 to symfony 4.4 I also got this error when composer commands.
This parameter seems so be used in config/packages/translation.yml.
Updating the symfony/translation recipe which no longer refers to %locale% but hardcode 'en' solves the problem for me.
Simply run composer recipes:install symfony/translation --force -v
I'm trying to use the S3 Cache Resolver of LiipImagineBundle to upload my cached thumbnails to S3 but I'm exepriencing some strange issues.
I'm using the AWS SDK v ^3.2:
"aws/aws-sdk-php": "^3.2",
I'm using Symfony2 and in my services.yml, I've configured the Aws\Credentials\Credentials class and the Aws\S3\S3Client that uses it to create the client:
shq.amazon.s3Credentials:
class: Aws\Credentials\Credentials
arguments: ["%amazon.s3.key%", "%amazon.s3.secret%"]
shq.amazon.s3:
class: Aws\S3\S3Client
arguments:
- version: %amazon.s3.version%
region: %amazon.s3.region%
credentials: "#shq.amazon.s3Credentials"
All works well, and I'm able to upload files to S3.
Now, the configuration of LiipImagineBundle: it seems that LiipImagineBundle has configuration rules that apply only to AWS SDK 2 and that causes "false positives" using the aws_s3 cache resolver.
I've tried at least three different configurations.
CONFIGURATION 1: FOR AWS SDK 2
liip_imagine:
resolvers:
default:
web_path: ~
cache_s3:
aws_s3:
client_config:
key: %amazon.s3.key%
secret: %amazon.s3.secret%
region: %amazon.s3.region%
version: %amazon.s3.version%
bucket: %amazon.s3.bucket%
get_options:
Scheme: 'https'
put_options:
CacheControl: 'max-age=86400'
cache: cache_s3
filter_sets:
thumb_purchase:
filters:
thumbnail: { size: [250, 250], mode: outbound }
interlace:
mode: line
This throws an exception:
An exception has been thrown during the rendering of a template
("Error retrieving credentials from the instance profile metadata
server. (cURL error 28: Connection timed out after 1006 milliseconds
(see http://curl.haxx.se/libcurl/c/libcurl-errors.html))") in
src/AppBundle/Resources/views/Store/show.html.twig at line 135.
This is thrown by the AWS SDK that is searching for credentials and doesn't find them.
So, this approach seems not working.
CONFIGURATION 2: USING Aws\Credentials (AWS SDK 3)
The way to pass credentials to S3Client is passing an instance of Aws\Credentials. I do this through a service so I can reuse the same credentials in other services (and that works as I use it to upload files to S3!):
shq.amazon.s3Credentials:
class: Aws\Credentials\Credentials
arguments: ["%amazon.s3.key%", "%amazon.s3.secret%"]
and in config.yml the :
liip_imagine:
resolvers:
cache_thumb_purchase:
aws_s3:
client_config:
version: %amazon.s3.version%
region: %amazon.s3.region%
credentials: "#shq.amazon.s3Credentials"
bucket: %amazon.s3.bucket%
get_options:
Scheme: 'https'
put_options:
CacheControl: 'max-age=86400'
filter_sets:
thumb_purchase:
cache: cache_thumb_purchase
filters:
thumbnail: { size: [250, 250], mode: outbound } # Transforms 50x40 to 32x26, no cropping
interlace:
# mode can be one of none,line,plane,partition
mode: line
As you can see, I pass the Credentials service to LiipImagineBundle but I get this error FROM Aws\ClientResolver:
InvalidArgumentException in ClientResolver.php line 296:
Invalid configuration value provided for "credentials". Expected Aws\Credentials\CredentialsInterface|array|bool|callable, but got string '#shq.amazon.s3Credentials' (length=25)
credentials: (Aws\Credentials\CredentialsInterface|array|bool|callable)
Specifies the credentials used to sign requests. Provide an
Aws\Credentials\CredentialsInterface object, an associative array of "key",
"secret", and an optional "token" key, false to use null credentials, or
a callable credentials provider used to create credentials or return null.
See Aws\Credentials\CredentialProvider for a list of built-in credentials
providers. If no credentials are provided, the SDK will attempt to load
them from the environment.
It seems that, instead of passing the class Credentials referenced by #shq.amazon.s3Credentials, it passes simply the string #shq.amazon.s3Credentials, so the ClientResolver, correctly, reports that the passed parameter is incorrect.
So, this configuration doesn't work, too.
CONFIGURATION 3: PASSING AN ARRAY TO S3Client (AWS SDK 3)
The third way of instantiating a S3Client is passing an associative array to hardcode credentials.
So I tried this configuration:
liip_imagine:
resolvers:
cache_thumb_purchase:
aws_s3:
client_config:
version: %amazon.s3.version%
region: %amazon.s3.region%
#credentials: "#shq.amazon.s3Credentials"
credentials:
key: %amazon.s3.key%
secret: %amazon.s3.secret%
...
But this time I receive an error from LiipImagineBundle, that seems doesn't accept an array as parameter:
InvalidTypeException in ScalarNode.php line 36: Invalid type for path
"liip_imagine.resolvers.cache_thumb_purchase.aws_s3.client_config.HERE_THERE_IS_DIRECTLY_MY_AWS_KEY".
Expected scalar, but got array.
I think that the configuration rules of the bundle have to be updated but i don't know how to do this as I'm not yet so confident with such kind of things.
So, how can I make LiipImagineBundle / Symfony to pass the class instead of the string that refers to the Credentialsclass? Is a fault of mine, or is something broken in LiipImagineBundle?
(Also, strange thing that I don't understand, instead of using the term "key" in the path, it use the value of "key" that is HERE_THERE_IS_DIRECTLY_MY_AWS_KEY.
So it reports a path like this liip_imagine.resolvers.cache_thumb_purchase.aws_s3.client_config.HERE_THERE_IS_DIRECTLY_MY_AWS_KEYinstead of a path like liip_imagine.resolvers.cache_thumb_purchase.aws_s3.client_config.key - that to me seems more correct, doesn't it?).
Have you tried this?
liip_imagine:
resolvers:
cache_thumb_purchase:
aws_s3:
client_config:
credentials:
key: %amazon.s3.key%
secret: %amazon.s3.secret%
version: %amazon.s3.version%
region: %amazon.s3.region%
bucket: %amazon.s3.bucket%
get_options:
Scheme: 'https'
put_options:
CacheControl: 'max-age=86400'
filter_sets:
thumb_purchase:
cache: cache_thumb_purchase
filters:
thumbnail: { size: [250, 250], mode: outbound } # Transforms 50x40 to 32x26, no cropping
interlace:
# mode can be one of none,line,plane,partition
mode: line
services:
admin.amazon.s3:
class: Aws\S3\S3Client
factory_class: Aws\S3\S3Client
factory_method: 'factory'
arguments:
- key: %amazon.s3.key%
secret: %amazon.s3.secret%
region: %amazon.s3.region%
version: %amazon.s3.version%
I'm starting to work on this LiipImagineBundle + KnpGaufretteBundle + "aws/aws-sdk-php": "^3.18" right now
I'm following the SonataAdminBundle documentation, so I've installed the Bundles and added them to AppKernel put now I'm stuck on the configuration.
I've used the basic config but I keep getting this error:
The service "sonata.admin.builder.orm_datagrid" has a dependency on a non-existent parameter "form.type_extension.csrf.enabled".
I've no idea what is this parameter nor how to set it properly.
in your app/config/yml you should have a line like :
framework:
#csrf_protection: ~
be sure it is not commented :
framework:
csrf_protection: ~
I am trying to deploy an existing Symfony 2.1 application to Azure. For this I am using the Azure Distribution Bundle, and I am trying to deploy assets to Azure as documented here.
However, I am getting an error when doing windowsazure:package to create the package:
Catchable Fatal Error: Argument 2 passed to WindowsAzure\DistributionBundle\Deployment\Assets\BlobStrategy::__construct() must be an instance of WindowsAzure\Blob\BlobRestProxy, none given, called in C:\IGPR\igpr\app\cache\azure\appAzureDebugProjectContainer.php on line 2361 and defined in C:\IGPR\igpr\vendor\beberlei\azure-distribution-bundle\WindowsAzure\DistributionBundle\Deployment\Assets\BlobStrategy.php line 35
Here is the relevant section of my config.yml:
windows_azure_distribution:
...
services:
blob:
default: UseDevelopmentStorage=true
azureprod: DefaultEndpointsProtocol=http;AccountName=myaccountname;AccountKey=MyVeryLongAccOUntKeY==
assets:
type: blob
connection_name: azureprod
Any ideas? Seems that the Blob proxy cannot be created. I get the same error if I try to use the local development storage.
The bundle is installed via Composer.
Looks like this was a bug in the Azure Distribution Bundle, which the maintainer has now fixed.