Finally, I fixed it by deleting all the files that control php and reinstalling php using homebrew.
---- Remove php ----
First, I used the following root ( cd /
) cd /
to find all files starting with "php"
find . -name "php*"
Depending on the results (you may have a lot), delete all the files that you need to delete (at the moment this is your opinion matters). For example, I deleted files in / usr / local and / usr / bin, but not in / Applications or / Homebrew. Examples:
rm -Rf /usr/bin/php* rm -Rf /usr/local/php*
Sometimes you may have a "permission denied" error even when using sudo, but in the end it did not cause problems.
---- Reinstall php ----
Once everything related to php has been removed, you can reinstall it using the following command line:
brew install php56
If you have a "libz not found" error, you will need to run the following command:
xcode-select
and restart the installation with
brew reinstall php56 --with-postgresql
If all goes well, you will need to define the date.timezone
field in php.ini and you will have a new php system. You can verify that the pdo_pgsql module is installed using this command line: php -m
.
---- Connect your database to your symfony project ----
First, you need to modify the app / config / parameters.yml file in your project by adding the following code:
# Postgresl psql_database_driver: pdo_pgsql psql_database_host: 127.0.0.1 psql_database_port: 5432 psql_database_name: your_database_name psql_database_user: your_user_name psql_database_password: your_password
The host and port fields may be different, but these are two default values ββfor symfony and the postgres database.
Then you will need to modify the app / config / config.yml file at the Doctrine configuration level as follows:
# Doctrine Configuration doctrine: dbal: default_connection: pgsql connections: #Mysql default: driver: pdo_mysql host: "%database_host%" port: "%database_port%" dbname: "%database_name%" user: "%database_user%" password: "%database_password%" charset: UTF8 #Postgresql pgsql: driver: pdo_pgsql host: "%psql_database_host%" port: "%psql_database_port%" dbname: "%psql_database_name%" user: "%psql_database_user%" password: "%psql_database_password%" charset: UTF8 #mapping_types: #geometry: string orm: auto_generate_proxy_classes: "%kernel.debug%" naming_strategy: doctrine.orm.naming_strategy.underscore auto_mapping: true
This is an example that you can adapt as you wish.
Now you can connect your database to your project using this command line:
php bin/console doctrine:database:create
If you already have entities in your src / AppBundle / Entity, you can create your tables with:
php bin/console doctrine:schema:update
Should be fine. Hope this helps someone else who is facing such issues.