Login to bookmark this video
Buy Access to Course
04.

The "symfony console" Command & server_version

|

Share this awesome video!

|

22 Comments

Sort By
Login or Register to join the conversation
Juergen-S avatar Juergen-S 2 years ago

You will need psql drivers for PHP, otherwise it will fail with "An exception occurred in the driver: could not find driver"

This will help:

sudo apt-get install php-pgsql

3 | Reply |

Hey Juergen,

Thanks for pointing it out. You're right, in order to work with the database you'll have to install their correspondent PHP extension, php-pgsql for Postgres and php-mysql for MySQL

Cheers!

| Reply |
Ali_M avatar Ali_M 1 year ago edited

Hello nice people at SymfonyCasts :)
Got a quick question: Why is that when we use make:entity command and we create non-nullable properties, we will end up having the following in our Entity class:

    #[ORM\Column(length: 255)]
    private ?string $filename = null;

The above filename property is set to not null during make:entity command process.
We keep adjusting this issue inside our entity files over and over again.

Thank you.

| Reply |

Hello @Ali_M

That's a complex question... in a typed PHP world you should have initialised values before any class manipulations, unfortunately inside Symfony especially with forms there will be lot of errors due to trying access not initialised fields. IIRC it was the cause for this behaviour.

Probably it may be changed sometime, but it requires lot of refactoring

Cheers!

| Reply |
Stanislaw avatar Stanislaw 2 years ago edited

I had an error trying to connect to postresql: An exception occured in the driver: could not find driver and resolved it by removing semicolon ; from php.ini file at lines extension=pdo_pgsql and extension=pgsql.

| Reply |

Hey Stanislaw,

Thank you for sharing this tip with others. Yeah, you need to make sure the DB driver is installed and enabled in your PHP config. Usually, it may happen out of the box but sometimes you need to tweak the config manually, depending on the OS and the way you're installing extensions.

Cheers!

| Reply |

Hello i am still having an error after modifying the ini file..

| Reply |

Hello, make sure you configure the right path in php.ini, in my case I use someting like:
extension="C:\Projects\Tutorials\Symfony\php-8.3.4\ext\php_pdo_pgsql"<br />extension="C:\Projects\Tutorials\Symfony\php-8.3.4\ext\php_pgsql"
Also you will see the errors when you run php.exe

1 | Reply |

Hey Frank,

Make sure you restarted your PHP-FPM in case you use it. If you use Symfony's built-in web server - make sure you restarted it as well to let it read new config parameters. If still the same error - it might be incorrect ini file then. You can find the correct one with php --ini command.

Cheers!

| Reply |
Algirdas avatar Algirdas 2 years ago edited

When running symfony console doctrine:database:create OR php ./bin/console doctrine:database:create I get the same error

An exception occurred in the driver: could not find driver

What could it be? Docker and Symfony are running and other doctrine commands seem to work

docker-composer.yml

version: '3'

services:
###> doctrine/doctrine-bundle ###
  database:
    image: postgres:${POSTGRES_VERSION:-14}-alpine
    environment:
      POSTGRES_DB: ${POSTGRES_DB:-app}
      # You should definitely change the password in production
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-!ChangeMe!}
      POSTGRES_USER: ${POSTGRES_USER:-app}
    volumes:
      - db-data:/var/lib/postgresql/data:rw
      # You may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data!
      # - ./docker/db/data:/var/lib/postgresql/data:rw
###< doctrine/doctrine-bundle ###

volumes:
###> doctrine/doctrine-bundle ###
  db-data:
###< doctrine/doctrine-bundle ###
| Reply |

Downloaded the project. Did everything from scratch... same issue

| Reply |

Hey Algirdas,

We're sorry to hear you're having trouble! We'll try to help you solve this issue.

Could you tell me what exactly steps are you following? Did you start from the start/ folder of the downloaded course code? Also, did you follow all the steps from the README.md file in that start/ folder?

Cheers!

1 | Reply |

Hello Victor,

So I am following from the very first tutorial. Finally 5mins ago I managed to fix it. I am using Ubuntu. My PHP version is 8.1.9
I ran these 2 commands:

sudo apt-get install php8.1-pgsql

and then restarting apache

sudo service apache2 restart

Now I have another issue :D

symfony console doctrine:database:create

I get: An exception occurred in the driver: SQLSTATE[08006] [7] connection to server at "127.0.0.1", port 49153 failed: FATAL: password authentication failed for user "app"

Any ideas how I can fix this? I did not change anything in .env or docker files. So password is still ChangeMe and user is app

| Reply |

Hey Algirdas,

I suppose you need to change those "ChangeMe" credentials to your real credentials to make it work ;)

Cheers!

1 | Reply |
Carlos-D avatar Carlos-D 2 years ago

I'm trying to connect to the database with symfony console doctrine:database:create but the error message I receive is 'SQLSTATE[08006] [7] connection to server at "127.0.0.1", port 5432 failed: Connection refused. Is the server running on that host and accepting TCP/IP connections?'

Thank you, ;)

| Reply |

HI,

Are you using docker? if so are you running it from PHPStorm console?

Cheers!

| Reply |

I'm using Docker and I've tried with Visual Code / PHPStorm and macOs native terminal / iTerm2 and Visual code / PHPStorm terminals and I get the same error.

If I try another postgresql database manager like DBngin (for example) I've no problem configuring the database.

I'm sure I'm missing some step but I don't know what, ;););););)

| Reply |

Hey Carlos-D!

Hmm, let's see :). Ok, so the error is this:

SQLSTATE[08006] [7] connection to server at "127.0.0.1", port 5432 failed: Connection refused

That tells me that Symfony is reading the DATABASE_URL from your .env file, as this is the default port used in that file. However, if you're using the Docker setup we've provided, that value should be overridden by a real DATABASE_URL env var. The process looks like this:

A) You run docker-compose up -d to start the Docker contain that ships with the code (did you do this step? It seems like the most likely candidate for the problem).

B) Once you do this, whenever you run symfony console ..., the symfony binary will detect that you have a Docker container called database running for postgres. It will then read the connection parameters to that Docker container and expose a real environment variable called DATABASE_URL that points to it.

C) This means that, when the command actually runs, it will talk to the Postgres instance in your Docker container.

Another way to see if the DATABASE_URL environment variable is being properly added by the symfony binary is to run symfony var:export --multiline to see if you see it in the list. It should look something like DATABASE_URL=postgres://symfony:ChangeMe@127.0.0.1:56986/app?sslmode=disable&charset=utf8.

Cheers!

| Reply |
Fouad B. avatar Fouad B. 2 years ago

the video stops playing due to an error happening at the 2:07 minute mark. Chrome throws an error: "The media playback was aborted due to a corruption problem or because the media used features your browser did not support.", safari will just freeze and seemingly play but both audio and video stop.

| Reply |

Hey Found,

We're sad to hear you're experiencing some problems with playing the video in Safari! What version of the browser do you use? Can you try to upgrade it to the latest? Mine is "Version 15.5 (17613.2.7.1.8)" and I cannot reproduce it, it works great for me. Please, could you try in a different browser, like Google Chrome? Is it the same error and at the same second for you?

Also, here's a little tip: as a temporary workaround you can download the video and watch it locally. I understand it's not perfect but could help in this specific case.

Cheers!

| Reply |

It is on MacOS Monteray 12.5
Safari Version 15.6 (17613.3.9.1.5)

And regarding Chrome, it happens in chrome with the stated error message.
Chrome Version 104.0.5112.79 (Official Build) (x86_64).

It only happens in this video on the mentioned minute mark.

Thanks for the tip ;) will do that.

Cheeers.

| Reply |

Hey Found,

Hm, that's weird that it happens only on the specific video and only at the specific time, and out team still can't reproduce it. It makes me thinks that it might be a temporary Vimeo issue because all our videos are hosted on Vimeo. I hope it will be better soon, but nothing much we can do here. I'd recommend you to download problematic videos and watch them locally.

Sorry for the inconveniences!

Cheers!

| Reply |

Delete comment?

Share this comment

astronaut with balloons in space

"Houston: no signs of life"
Start the conversation!