services.yml
mea.twig.JsExtension:
alias: Mea\CoreBundle\Twig\MeaExtension
public: true
arguments: ["#service_container","#kernel", "#mea.metatags", "#mea.asset"]
tags:
- { name: twig.extension }
give error
InvalidArgumentException
Unable to replace alias "mea.twig.JsExtension" with actual definition "Mea\CoreBundle\Twig\MeaExtension".
in ReplaceAliasByActualDefinitionPass.php (line 57)
at ReplaceAliasByActualDefinitionPass->process(object(ContainerBuilder))
in Compiler.php (line 141)
at Compiler->compile(object(ContainerBuilder))
in ContainerBuilder.php (line 759)
at ContainerBuilder->compile()
in Kernel.php (line 643)
Symfony 3.4
There are 4 possible causes of it and they might be perfectly undersended by exceptions of Symfony\Component\DependencyInjection\Exception\InvalidArgumentException type:
ServiceNotFoundException;
ParameterNotFoundException;
EnvNotFoundException;
EnvParameterException.
I'm sure first exception is the the real cause of your problem.
Related
I'm trying to learn how to use script plugin. I'm following script plugin docs here but not able to make it work.
I've tried to use the plugin in two ways. The first, when cloudify.interface.lifecycle.start operation is mapped directly to a script:
tosca_definitions_version: cloudify_dsl_1_3
imports:
- 'http://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml'
node_templates:
Import_Project:
type: cloudify.nodes.WebServer
capabilities:
scalable:
properties:
default_instances: 1
interfaces:
cloudify.interfaces.lifecycle:
start:
implementation: scripts/create_project.sh
inputs: {}
The second with a direct mapping:
tosca_definitions_version: cloudify_dsl_1_3
imports:
- 'http://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml'
node_templates:
Import_Project:
type: cloudify.nodes.WebServer
capabilities:
scalable:
properties:
default_instances: 1
interfaces:
cloudify.interfaces.lifecycle:
start:
implementation: script.script_runner.tasks.run
inputs:
script_path: scripts/create_project.sh
I've created a directory named scripts and placed the below create_project.sh script in this directory:
#! /bin/bash -e
ctx logger info "Hello to this world"
hostname
I'm getting errors while validating the blueprint.
Error when operation is mapped directly to a script:
[2019-04-13 13:29:40.594] [DEBUG] DslParserExecClient - got output from dsl parser Could not extract plugin from operation mapping 'scripts/create_project.sh', which is declared for operation 'start'. In interface 'cloudify.interfaces.lifecycle' in node 'Import_Project' of type 'cloudify.nodes.WebServer'
in: /opt/cloudify-composer/backend/dev/workspace/2/tmp-27O0e1t813N6as
in line: 3, column: 2
path: node_templates.Import_Project
value: {'interfaces': {'cloudify.interfaces.lifecycle': {'start': {'implementation': 'scripts/create_project.sh', 'inputs': {}}}}, 'type': 'cloudify.nodes.WebServer', 'capabilities': {'scalable': {'properties': {'default_instances': 1}}}}
Error when using a direct mapping:
[2019-04-13 13:25:21.015] [DEBUG] DslParserExecClient - got output from dsl parser node 'Import_Project' has no relationship which makes it contained within a host and it has a plugin 'script' with 'host_agent' as an executor. These types of plugins must be installed on a host
in: /opt/cloudify-composer/backend/dev/workspace/2/tmp-279QCz2CV3Y81L
in line: 2, column: 0
path: node_templates
value: {'Import_Project': {'interfaces': {'cloudify.interfaces.lifecycle': {'start': {'implementation': 'script.script_runner.tasks.run', 'inputs': {'script_path': 'scripts/create_project.sh'}}}}, 'type': 'cloudify.nodes.WebServer', 'capabilities': {'scalable': {'properties': {'default_instances': 1}}}}}
What is missing to make this work?
I also found the Cloudify Script Plugin examples from their documentation do not work: https://docs.cloudify.co/4.6/working_with/official_plugins/configuration/script/
However, I found I can make the examples work by adding an executor line in parallel with the implementation line to override the host_agent executor as follows:
tosca_definitions_version: cloudify_dsl_1_3
imports:
- 'http://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml'
node_templates:
Import_Project:
type: cloudify.nodes.WebServer
capabilities:
scalable:
properties:
default_instances: 1
interfaces:
cloudify.interfaces.lifecycle:
start:
implementation: scripts/create_project.sh
executor: central_deployment_agent
inputs: {}
Hi I am using spring boot version - 2.0.0.RC1. I have simple service running #port 9400.
My application.properties have below configuration:
spring.main.banner-mode = CONSOLE
spring.profiles.active = ${profile:local}
server.compression.enabled = true
server.compression.min-response-size = 1
server.compression.mime-types = application/json,application/xml,text/xml,text/plain
banner.charset = UTF-8
management.endpoints.health.show-details=true
management.server.address: 127.0.0.1
management.endpoints.web.expose: health,info,metrics,mappings,trace
management.endpoints.health.show-details: true
management.endpoints.health.time-to-live: 2000
management.security.enabled: false
management.health.defaults.enabled: false
management.health.diskspace.enabled: true
My build.gradle has :
dependencies {
// Spring Boot
compile group: 'org.springframework.boot', name: 'spring-boot-starter-webflux', version: springBootVersion
compile group: 'org.springframework.boot', name: 'spring-boot-starter-actuator', version: springBootVersion
}
My gradle.properties:
springBootVersion = 2.0.0.RC1
When I point to http://127.0.0.1:9400/health
I get error screen as attached snapshot.
What am I missing?
The show-details value that you are providing is not a valid one...
Anyway, in Spring Boot 2.0 the actuator endpoints (like the health) are remapped to /actuator/*.
Now, the health is located at /actuator/health.
More info at the release notes in https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.0.0-RC2-Release-Notes#health-endpoint
Just add the following property in application.properties file:
management.health.defaults.enabled=false
I'ld like to use the new Symfony 3 Cache Component in a project.
I can use it if I define my services by hand like this:
app.cache.adapter.array:
class: 'Symfony\Component\Cache\Adapter\ArrayAdapter'
app.redis.client:
class: Predis\Client
factory: ['Symfony\Component\Cache\Adapter\RedisAdapter', 'createConnection']
arguments: ["%redis_dsn%", {timeout: 5}]
app.cache.adapter.redis:
class: Symfony\Component\Cache\Adapter\RedisAdapter
abstract: true
arguments:
-
- "api"
- 0
app.cache.adapter.chain:
class: 'Symfony\Component\Cache\Adapter\ChainAdapter'
abstract: true
arguments:
- ['#app.cache.adapter.array', "#app.cache.adapter.redis"]
- 0
cache.api:
parent: "app.cache.adapter.chain"
But as soon as I use the cache.pool tag or the framework pools configuration to get data in the profiler, I've got an exception
framework:
cache:
pools:
cache.api:
adapter: "app.cache.adapter.chain"
public: true
default_lifetime: 0
clearer: ~
And here is the exception
(1/1) ContextErrorException
Catchable Fatal Error: Argument 1 passed to Symfony\Component\Cache\Adapter\ChainAdapter::__construct() must be of the type array, string given, called in /var/www/julien/htdocs/sccd/website/var/cache/dev/appDevDebugProjectContainer.php on line 4032 and defined
in ChainAdapter.php (line 37)
at ChainAdapter->__construct('+FJMe7Pj5l', 0)in appDevDebugProjectContainer.php (line 4032)
at appDevDebugProjectContainer->getCache_Api_RecorderInnerService()in appDevDebugProjectContainer.php (line 623)
at appDevDebugProjectContainer->getCache_ApiService()in classes.php (line 3292)
at Container->get('cache.api')in appDevDebugProjectContainer.php (line 2629)
Can anyone help me on this ?
I'm using the Symfony v3.3.11, and predis/predis v1.1.1 for redis connection.
Thanks
Receiving the following error message when trying to run my project.
Fatal error: Uncaught exception 'Doctrine\ODM\PHPCR\Translation\MissingTranslationException' with message 'The locale 'en' is not present in the list of available locales' in /var/www/sources/piccolo-standard/vendor/doctrine/phpcr-odm/lib/Doctrine/ODM/PHPCR/Translation/LocaleChooser/LocaleChooser.php on line 133
Doctrine\ODM\PHPCR\Translation\MissingTranslationException: The locale 'en' is not present in the list of available locales in /var/www/sources/piccolo-standard/vendor/doctrine/phpcr-odm/lib/Doctrine/ODM/PHPCR/Translation/LocaleChooser/LocaleChooser.php on line 133
And the following stack trace:
# Time Memory Function Location
1 0.0040 240752 {main}( ) ../app.php:0
2 0.0299 643576 Symfony\Component\HttpKernel\HttpCache\HttpCache->handle( ) ../app.php:20
3 0.0309 657488 Symfony\Component\HttpKernel\HttpCache\HttpCache->lookup( ) ../HttpCache.php:193
4 0.0316 659008 Symfony\Component\HttpKernel\HttpCache\HttpCache->fetch( ) ../HttpCache.php:329
5 0.0317 665184 Symfony\Bundle\FrameworkBundle\HttpCache\HttpCache->forward( ) ../HttpCache.php:429
6 0.4876 9740256 Symfony\Component\HttpKernel\HttpCache\HttpCache->forward( ) ../HttpCache.php:60
7 0.4877 9742120 Symfony\Component\HttpKernel\Kernel->handle( ) ../HttpCache.php:466
8 0.4957 9838264 Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel->handle( ) ../Kernel.php:187
That is all what I am getting as error report.
What could be going wrong?
edit:
Here is a part my config.yml;
framework:
#esi: ~
translator: { fallback: en }
secret: %secret%
router: { resource: "%kernel.root_dir%/config/routing.yml" }
form: true
csrf_protection: true
templating: { engines: ['twig'] } #assets_version: SomeVersionScheme
default_locale: %locale%
session: ~
edit 2:
After configuring config.yml;
Warning: filemtime(): stat failed for /var/www/sources/piccolo-standard/app/config/config.yml in /var/www/sources/piccolo-standard/vendor/symfony/symfony/src/Symfony/Component/Config/Resource/FileResource.php on line 68
Fatal error: Uncaught exception 'Doctrine\ODM\PHPCR\Translation\MissingTranslationException' with message 'The locale 'en' is not present in the list of available locales' in /var/www/sources/piccolo-standard/vendor/doctrine/phpcr-odm/lib/Doctrine/ODM/PHPCR/Translation/LocaleChooser/LocaleChooser.php on line 133
Doctrine\ODM\PHPCR\Translation\MissingTranslationException: The locale 'en' is not present in the list of available locales in /var/www/sources/piccolo-standard/vendor/doctrine/phpcr-odm/lib/Doctrine/ODM/PHPCR/Translation/LocaleChooser/LocaleChooser.php on line 133
Edit 3: Solution
The problem was a combining of two issues. The first one was the config.yml. Make sure that the 'doctrine_phpcr.odm.locales' section is set as followed (or something a like, considering what languages you support):
locales:
en: [de, fr]
de: [en, fr]
fr: [en, de]
And the second problem was the absence of database connection configured in 'parameters.yml'. Without connection to my database, the server most likely tried to load an English object (perhaps a DateTime) and failed to load.
This is may be stupid, but have you tried to quote your language value ?
like this :
Translator : { fallback : 'en' }
in all of our symfony project we use the locale variable instead of an hard value
Translator : { fallback : "%locale%" }
according to this source code :
https://github.com/doctrine/phpcr-odm/blob/master/lib/Doctrine/ODM/PHPCR/Translation/LocaleChooser/LocaleChooser.php
the language definition should be quoted ( line 37 )
/**
* locale fallback list indexed by source locale
*
* example:
* array(
* 'en' => array('en', 'de', 'fr'),
* 'fr' => array('fr', 'de', 'en'),
* 'de' => array('de', 'fr', 'en'),
* )
*/
protected $localePreference;
hope that will help you
EDIT : Did you correctly setup you php-cr parameters ?
here is an example from symfony.com
doctrine_phpcr:
odm:
# ...
locales:
en: [de, fr]
de: [en, fr]
fr: [en, de]
locale_fallback: hardcoded
http://symfony.com/doc/current/cmf/bundles/phpcr_odm/multilang.html
Currently, when writing a unit test for my Symfony2 bundle, I explicitly set ini_set('display_errors', 1) to make sure I see any errors I made in writing my unit test. This is particularly helpful for fatal errors, such as those resulting from typos in method names.
Example:
# src/Foo/BarBundle/Tests/Security/RoutePermissionCheckerTest.php
namespace Foo\BarBundle\Tests\Security;
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
class RoutePermissionCheckerTest extends TestCase
{
public function testIndex()
{
ini_set('display_errors', 1);
$this->nonExistentMethod();
}
}
Output:
Configuration read from /Users/maurits_dekkers/Sites/hobby/symfony/saas-seed/app/phpunit.xml.dist
...
Fatal error: Call to undefined method Bb\UserBundle\Tests\Security\RoutePermissionCheckerTest::nonExistentMethod() in /Users/maurits_dekkers/Sites/hobby/symfony/saas-seed/src/Bb/UserBundle/Tests/Security/RoutePermissionCheckerTest.php on line 18
Call Stack:
0.0314 635432 1. {main}() /Users/maurits_dekkers/pear/bin/phpunit:0
0.5501 1191328 2. PHPUnit_TextUI_Command::main() /Users/maurits_dekkers/pear/bin/phpunit:46
0.5502 1192056 3. PHPUnit_TextUI_Command->run() /Users/maurits_dekkers/pear/share/pear/PHPUnit/TextUI/Command.php:129
1.2241 7133440 4. PHPUnit_TextUI_TestRunner->doRun() /Users/maurits_dekkers/pear/share/pear/PHPUnit/TextUI/Command.php:176
1.2619 7653720 5. PHPUnit_Framework_TestSuite->run() /Users/maurits_dekkers/pear/share/pear/PHPUnit/TextUI/TestRunner.php:349
14.0128 37804208 6. PHPUnit_Framework_TestSuite->run() /Users/maurits_dekkers/pear/share/pear/PHPUnit/Framework/TestSuite.php:705
14.0130 37804608 7. PHPUnit_Framework_TestSuite->runTest() /Users/maurits_dekkers/pear/share/pear/PHPUnit/Framework/TestSuite.php:745
14.0130 37804608 8. PHPUnit_Framework_TestCase->run() /Users/maurits_dekkers/pear/share/pear/PHPUnit/Framework/TestSuite.php:775
14.0131 37804608 9. PHPUnit_Framework_TestResult->run() /Users/maurits_dekkers/pear/share/pear/PHPUnit/Framework/TestCase.php:783
14.0131 37805600 10. PHPUnit_Framework_TestCase->runBare() /Users/maurits_dekkers/pear/share/pear/PHPUnit/Framework/TestResult.php:648
14.0134 37846840 11. PHPUnit_Framework_TestCase->runTest() /Users/maurits_dekkers/pear/share/pear/PHPUnit/Framework/TestCase.php:838
14.0134 37848304 12. ReflectionMethod->invokeArgs() /Users/maurits_dekkers/pear/share/pear/PHPUnit/Framework/TestCase.php:983
14.0134 37848336 13. Bb\UserBundle\Tests\Security\RoutePermissionCheckerTest->testIndex() /Users/maurits_dekkers/pear/share/pear/PHPUnit/Framework/TestCase.php:983
However, there must be a better way by means of a configuration setting. I've tried adding an extra Monolog setting to my config_test.yml:
# app/config/config_test.yml
monolog:
handlers:
console:
type: console
bubble: false
level: info
but that does not result in PHP errors being reported during my unit test. The unit test simply stops running.
Is there an easy way to configure my Symfony2 project to always report errors during a unit test?
You might want to set the following parameters to true in your PHPUnit configuration file (app/config/phpunit.xml):
convertErrorsToException
convertNoticesToExceptions
convertNoticesToExceptions