PHP Symfony SQL Queries button Missing from Toolbar - php

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.

Related

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.

Symfony 2 Doctrine MS SQL Error

I have started working on a Symfony 2.3 project where I need to convert a financial website written in classic Asp to Php.
The client has Ms-Sql database which is to be used with Symfony 2.3 and doctrine, I have made the database and loaded the empty tables from the schema files.
Now whenever i try to generate entities from the database(Ms-Sql) I get the following error:
Doctrine\DBAL\DBALException
Unknown database type timestamp requested, Doctrine\DBAL\Platforms\SQLServer2008Platform may not support it
Does anyone know how to solve the problem or what should I do to avoid such a situation?
Kindly help me as I am new to Symfony 2.3, Thank you
You can add your own types following doctrine doc about the subject :
http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/cookbook/mysql-enums.html
this is concerning enum type but you can use it with any type like timestamp and link it to string type or whatever other supported type by your database which fit you best.
src/My/Project/MyProjectBundle.php
public function boot()
{
$em = $this->container->get('doctrine.orm.entity_manager');
$em->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('timestamp','string');
}
and normally all your timestamp types should be translated as string.
The configuration below works on Synfony 3.2
1) in config.yml add the new type under types and map it under mssql connection
# Doctrine Configuration
doctrine:
dbal:
types:
timestamp: AppBundle\Type\Timestamp
..
..
connections:
mssql:
driver: sqlsrv
host: "%mssql_host%"
port: "%mssql_port%"
dbname: "%mssql_db_name%"
user: "%mssql_user%"
password: "%mssql_password%"
mapping_types:
timestamp: timestamp
2) Create the class AppBundle\Type\Timestamp as for the following url:
https://github.com/mmerian/doctrine-timestamp/blob/master/lib/DoctrineTimestamp/DBAL/Types/Timestamp.php
3) generate entities from the database with the following command:
php bin/console doctrine:mapping:import --force AppBundle xml --em=mssql

Behat with Mink

Does anyone know how to successfully configure Mink to work with Behat? In case if anyone doesn't know, Behat is a BDD(Behaviour-Driven Development) framework for PHP and Mink provides a browser emulators abstraction layer to test with.
You can find out more about Behat at http://behat.org/ and Mink at https://github.com/Behat/Mink or http://www.knplabs.com/fr/blog/one-mink-to-rule-them-all
Basically i followed the instructions at http://www.knplabs.com/fr/blog/one-mink-to-rule-them-all to configure my Mink to work with my Behat. My behat.yml, the one located inside the Behat folder, not the Mink folder, is as follows:
default:
paths:
features: %%BEHAT_CONFIG_PATH%%/features
formatter:
name: progress
pretty:
formatter:
name: pretty
parameters:
multiline_arguments: false
default:
environment:
parameters:
start_url: http://localhost/
imports:
- mink/behat.yml
I also have the following code in my features/support/boostrap.php
require_once 'mink/autoload.php';
However, having the following code in my features/support/env.php
$world->client = new \Goutte\Client;
would give me a PHP Fatal error: Class 'Goutte\Client' not found in terminal(OSX) when i use the behat command. This happens even if i have the goutte.phar inside my behat/Mink/Vendor/Goutte folder.
Hope anyone can enlighten me on where i went wrong and if there was any part in the question where I wasn't being clear about it, do let me know. Thanks a lot.
Here it is: https://github.com/knplabs/mink-demo ;-)
Basically, with Mink, you don't need to create or require Goutte client it's done by Mink automatically. Your $world was also enhanced and now you're able to get mink session inside step definitions:
$downloadsLink = $world->getSession()->getPage()->findLink('downloads');
Also, you've forgot to include PHPUnit!
See mink-demo for getting great example ;-)

Symfony Jobeet Tutorial Day 3, databases.yml error

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

Categories