Symfony Jobeet Tutorial Day 3, databases.yml error - php

I'm new to Symfony and I'm going through the Jobeet tutorial v1.4 for
Doctrine. I am currently stuck on Day 3. I've followed all the
instructions on configuring the database and building models and
modules; however, when I try to access
"http://localhost:8080/frontend_dev.php" I receive the following
error:
'Configuration "config/databases.yml" does not exist or is unreadable.'
My config/databases.yml file looks like this:
all:
doctrine:
class: sfDoctrineDatabase
param:
dsn: 'mysql:host=localhost;dbname=jobeet'
username: root
password: mysecret
Creating the tables and loading the fixtures seem to work fine after checking the database with phpmyadmin. Any help would be appreciated.
Thank you!

I tried what's in the Jobeet from Day 1 to 3 and it works on my local machine, maybe what you have there is some file permission issue that is preventing your symfony to load the config/databases.yml so please change permissions as needed (chmod in linux).
Not sure if this will solve the problem but I think this is worth to try, execute php symfony cc or simply clear the cache folder and load up again your app in the browser, since the config/databases.yml is to be cached as config_databases.yml.php (you can take a look on /cache/frontend/dev/config/)

phpmyadmin? arrggggghhhhhhh =P
Anyway, your identation is wrong.
It should be like this:
all:
doctrine:
class: sfDoctrineDatabase
param:
dsn: "mysql:host=localhost;dbname=jobeet"
username: root
password: mysecret
As for the error, if you're on a mac, change the permissions using chmod. :-)

If you're stuck on a problem with databases.yml, this symfony databases.yml configuration reference could be useful: www.symfonyreference.com/databases-yml

Related

Problem with layer when using serverless-offline with Bref

I'm trying to run a Symfony application with Bref and serverless-offline. I know that Bref doesn't officially support serverless-offline, but I want to give it a shot; this thread - https://github.com/brefphp/bref/issues/875 - implies that it should be possible but I'm not getting the error described there yet.
When I run sls invoke local -f MyLambda I get this error:
{"errorType":"exitError","errorMessage":"RequestId: 09256631-dcc7-1775-350e-b0c10a2c9c00 Error: Couldn't find valid bootstrap(s): [/var/task/bootstrap /opt/bootstrap]"}
So I assume that serverless-offline fails to get the layer correctly. The directory .serverless/layers contains a sub-structure php-81-fpm/18 for the PHP layer but it is empty.
What's important is that I'm running this setup in a development Docker container. I mounted the docker socket so the Docker daemon on the host is used.
The serverless.yml looks like this (simplified):
plugins:
- ./vendor/bref/bref
- serverless-offline
functions:
MyLambda:
handler: public/index.php
layers:
- ${bref:layer.php-81-fpm} # also tried with 'arn:aws:lambda:eu-central-1:209497400698:layer:php-81-fpm:18'
custom:
serverless-offline:
host: 0.0.0.0
useDocker: true
dockerHost: host.docker.internal
I'm happy to provide further information, please let me know. Don't hesitate to suggest "low-level" things as I'm quite new to this ecosystem. Thanks for your help!

Symfony "Invalid env" - only "word" characters are allowed

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

empty Symfony's profiler?

I recently discovered that my profiler is not working. Every time I try to open the profiler from /app_dev.php/_profiler/empty/search/results?ip=&limit=10 I get this empty profiler page:
With default and customc onfiguration. Here the custom one:
framework:
profiler:
dsn: 'file:/tmp/symfony-profiler'
And here a more precise configuration:
framework:
profiler:
dsn: "file:%kernel.root_dir%/../var/cache/%kernel.environment%/profiler"
No calls are stored in theprofiler. No log keep trace of what happens under the carpet.
Symfony needs the same file permissions to write the profiling data as it would for logs or the cache. Does Symfony write the files if the DSN is left at the default which would write them into var/cache/dev/profiler (or app/var with an older version).
It's also possible that the profiler service has been overridden, which can be checked with bin/console debug:container profiler and other such tools.

reverse database won't work from terminal (PROPEL / BAKE CAKEPHP)

I've been trying to generate model classes from a local database using both propel and bake for cakephp , it seems that i have the same problem :
When I try to acces the database through bake or propel it gives me an error that it can't open the connection:
So I tried this :
I try to acces the database from the application using pdo it works just fine!!!
When I tried to acces database through terminal it's also working !!!
I really don't know what's the problem here !
You most likely have a separate php.ini config file for CLI and pdo_mysql is not loaded for CLI.

PHP Symfony SQL Queries button Missing from Toolbar

Hi am I am using Symfony to develop the Jobeet website while I try to learn it for a bigger project and it is going resonably well so far.
However I have just got to page 73 where it mentiones clicking on the SQL Query button to debug your queries generated, I don't seem to have this button, even on pages that are definately using SQL.
Databases.yml
all:
propel:
class: sfPropelDatabase
param:
dsn: 'mysql:host=localhost;dbname=jobeet;'
username: root
password: password
encoding: utf8
Does anyone know why it wouldn't be showing up?
Is there any more information I can provide to help?
If I am not mistaken, you need something like this:
File: config/databases.yml
dev:
propel:
param:
classname: DebugPDO
Now, if you have web_debug: on in your application settings.yml (for the dev environment), it should work fine.

Categories