CodeIgniter initial configuration |
Hi, I'm from CI3 and I try to migrate on CI4.
I'm following this tutorial : https://codeigniter.com/user_guide/tutorial/index.html Initial configuration is not clear. I do not understand what I should do to get a proper configuration of CodeIgniter. Here are some of my interrogations : I read the CI_ENVIRONMENT variable can be set in the .htaccess file and in the .env file. Where should I put the configuration ? I read the baseURL variable can be set in /Config/app.php, and in the .env file. Where should I configure baseURL ? I read the database configuration can be set in the /Config/database.php and in the .env file. Where should I configure the DB ? I try to configure the DB in /Config/database.php and in the .env file, but I can't get ride of this error : Quote:You have not selected a database type to connect to.You have not selected a database type to connect to. I can't figure out how to properly configure CI4 for development on a local apache server and for production on a remote apache serveur. I read the doc dozen of times, but I still don't understand the configuration philosophy of CI4. Any light is welcome.
You have to set the data for the connection to the database on app / Config / database.php
It's recommended to set in .env, so you can have a different .env file on your severs.
Please note you need to rename/copy your env into .env - There need to be a . (dot). Code: CI_ENVIRONMENT = development Quote:jreklund It's recommended to set in .env, so you can have a different .env file on your severs. Ha, OK, that was not clear for me after reading the documentation. Quote:Please note you need to rename/copy your env into .env - There need to be a . (dot). So the database configuration in the /Config/Database.php is not used, right ? Hum it's not working I still have the following error : Code: InvalidArgumentException When I look at the arguments of CodeIgniter\Database\Database->load ( arguments ), this is the arguments set in /Config/Database, not the parameters set in .env.
Can you post your .env file here?
.env overrides your settings in /app/Config/(all files) (05-05-2020, 12:10 PM)jreklund Wrote: Can you post your .env file here? OK, .env overrides settings !!! Everything is clear now. By the way, it works, I reverted the file /Config/Database.php. (As it was not working, I try many options, and I probably changed something that prevent connecting to MySQL). Let's try PDO now ! Thank you for your help.
PDO are not ported yet, so you can't use that driver.
https://codeigniter.com/user_guide/intro...ments.html (05-05-2020, 12:27 PM)jreklund Wrote: PDO are not ported yet, so you can't use that driver. This is probably why it was not working! Do you know configuration settings for PDO is explained in the documentation : https://codeigniter.com/user_guide/datab...figuration Quote:Some database drivers (such as PDO, PostgreSQL, Oracle, ODBC) might require a full DSN string to be provided. If that is the case, you should use the ‘DSN’ configuration setting, as if you’re using the driver’s underlying native PHP extension, like this:
Okay, that's wrong at this time. CI4 user guide are based on CI3, so must have been missed.
|
Welcome Guest, Not a member yet? Register Sign In |