i want to set up admin for my symfony projet :
symfony composer req "admin:^4"
Then creating the controller :
symfony console make:admin:dashboard
After starting the server and going to /admin url i get following error : Variable "dashboard_controller_class" does not exist
I searched but not found where to declare this variable ? and what is it about ?
Could you help me please ?
I tried adding to the service.yaml file :
parameters:
dashboard_controller_class: App\Controller\Admin\DashboardController
services:
App\Controller\Admin\DashboardController:
class: '%dashboard_controller_class%'
SOLVED
It is the cache that generated the error, I just have to delete the corresponding cache folder
Thank you
Related
Im facing a problem to my website https://market.dhruvigroup.in , i tired by improving memory linit and setting up new mySql Databased ! anyone can please help me to resolve this problme ?
debug infor enabled in this url to view error log , please visit the mentioned url
Environment information
Laravel version : 8.23.1
Laravel locale : en
Laravel config cached : false
PHP version : 7.4.16
It looks like the route name is not defined.
You will have to post the contents of your routes/web.php for us to be helpful. Does the route appear when you do php artisan route:list?
Your routes file must contain something like
Route::get('/', [ControllerName::class, 'methodName'])->name('LaravelInstaller::welcome');
I'm trying to implement google recaptcha v2 with livewire but I get some issues :
The issue that I get is when I try to call RECAPTCHA_SITE_KEY from the .env file it display me this error message in Dev Console :
"Uncaught Error: Missing required parameters: sitekey"
it confusing because the site key is correct and is already exist inside .env file.
Wile I remove the {{ env('RECAPTCHA_SITE_KEY') }} from data-sitekey and add the site key it work
Not Working example :
data-sitekey="{{ env('RECAPTCHA_SITE_KEY') }}"
"Uncaught Error: Missing required parameters: sitekey"
Working example :
data-sitekey="XXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
Where this problem coming from ?
First, double check that is is spelled exactly the same in your .env. Second, run php artisan cache:clear in case your config is cached. Third, attempt env('RECAPTCHA_SITE_KEY'); from php artisan tinker and see what results you get.
I have symfony 4 setup
in services.yml I have the following configured service
MyCompany\Interfaces\QueueProducerInterface:
class: MyCompany\Service\KafkaProducer
arguments:
$queueConfig: '#queue_config'
I want to change the setting dynamically in my .envfile, so I can inject it later, depending on the env (dev, production)....so I tried something like this:
in .env
QUEUE_DRIVER="MyCompany\Service\KafkaProducer"
and now in services.yaml
MyCompany\Interfaces\QueueProducerInterface:
# class: MyCompany\Service\KafkaProducer
class: '.%env(QUEUE_DRIVER)%'
arguments:
$queueConfig: '#queue_config'
but when I run for instance composer update I get a container error
Script cache:clear returned with error code 1
!!
!! In Compiler.php line 112:
!!
!! Incompatible use of dynamic environment variables "QUEUE_DRIVER" found in p
!! arameters.
!!
!!
!! In AbstractRecursivePass.php line 123:
!!
!! Invalid service "MyCompany\Interfaces\QueueProducerInterface": class ".%env(
!! QUEUE_DRIVER)%" does not exist.
!!
!!
how do I solve this problem? or better said, how can I set the value of this class dynamically depending on ENV.
I solved it, by creating a services.yaml inside the folder config/packages/dev/ and also `config/packages/prod/' with different settings.
In newer versions of symfony you can do that in a single services.yaml using the when#xxx syntax and use an interface, like this:
For example:
parameters:
my.nice.service.class: Some\NameSpace\RealServiceClass
when#dev:
parameters:
my.nice.service.class: Some\DevelHelper\RealServiceClass
Some\NameSpace\WorkerInterface:
class: '%my.nice.service.class%'
In your consuming class just typehint the Some\NameSpace\WorkerInterface interface in the constructor and it will be injected properly.
Of course the interface Some\NameSpace\WorkerInterface must exist in the code and both RealServiceClass and RealServiceClass must implement the interface.
I'm currently trying to get a Symfony project up and running. The problem is when I try to setup the database I keep getting
[Symfony\Component\DependencyInjection\Exception\InvalidArgumentException]
Invalid env(resolve:DATABASE_URL) name: only "word" characters are allowed.
I edited the .env file to have my local database credentials. The DATABASE_URL variable looks like the following:
DATABASE_URL="mysql://user:pass#192.168.10.10:3306/db_name?charset=utf8mb4&serverVersion=5.7"
Where of course, user, pass and db_name are the credentials.
Any idea on how to solve this problem?
I found something in doctrine recipe. It's likely because you are using symfony 3.3 with symfony/flex so you would need to remove the resolve keyword, ie. in your config/packages/doctrine.yaml :
doctrine:
dbal:
url: '%env(DATABASE_URL)%'
See this news for more information
I have a site built on Symfony framework and I had to add a legacy php script launched directly in the web directory.
I also have to share session's data between the Symfony framework controllers and the stand-alone php script.
Sessions on my server and the Symfony framework are configured to be in a memcached server (127.0.0.1 11211).
Here are my Symfony config files :
parameters.yml
session_memcached_host: 127.0.0.1
session_memcached_port: 11211
session_memcached_prefix: 'BPY_'
session_memcached_expire: 3600
config.yml
imports:
- { resource: session.yml }
...
session:
handler_id: session.handler.memcached
session.yml
services:
session.memcached:
class: Memcache
arguments:
persistent_id: %session_memcached_prefix%
calls:
- [ addServer, [ %session_memcached_host%, %session_memcached_port% ]]
session.handler.memcached:
class: Symfony\Component\HttpFoundation\Session\Storage\Handler\MemcacheSessionHandler
arguments: [#session.memcached, { prefix: %session_memcached_prefix%, expiretime: %session_memcached_expire% }]
Session in the Symfony controllers are set and read using :
$request->getSession->get('key');
$request->getSession->set('key', $value);
In the stand-alone old php script, I use the global session array to set and get data. And in theory, to allow Symfony and my script share data I set and get data in :
$_SESSION['_sf2_attributes']
So, finally with this configuration, when I set data in the symfony controllers I do not see it in the stand-alone php script and when I set data in the php script I do not see it in the Symfony controllers.
What is wrong in my configuration or my code?
You should check the Bridge a legacy Application with Symfony Sessions
but overall you can configure it in the following way:
framework:
session:
storage_id: session.storage.php_bridge
handler_id: ~
I finally solved the problem.
In the parameters.yml file I put :
session_memcached_prefix : ''
instead of :
session_memcached_prefix : 'BPY_'
and the two envirennements can share sessions data.
In the Symfony controllers I still use
$request->getSession->get('key');
$request->getSession->set('key', $value);
And in the stand-alone php script I use set and get data in this array :
$_SESSION['_sf2_attributes']
So
$_SESSION['_sf2_attributes']['key'] = $value