2 Baseurl |
Yes, as CodeIgniter are just plain PHP you can access it everywhere. Just modify your /app/Config/App.php and you are gold. Depending on where that setting comes from, you may need to validate it first.
(08-22-2020, 12:00 AM)jreklund Wrote: Yes, as CodeIgniter are just plain PHP you can access it everywhere. Just modify your /app/Config/App.php and you are gold. Depending on where that setting comes from, you may need to validate it first. But it's a variable in a class , i cannot use if statement : Code: if ($_SERVER['SERVER_NAME']== 'http://localhost:8080/') {
You can always put it in the __construct or you can modify your /public/index.php to handle all your "Environment variables" set by Apache/Nginx, and define it (just as we do with FCPATH). And use the defined name in /app/Config/App.php.
With the example given, it's just better to have two different .env files, if you just need different live and development settings.
Thank's work fine , can i do the same for db ? but migrate don't work because $_SERVER['SERVER_NAME'] isn't isset
Yes, I'm doing it for multiple values. Never used migrate thought, but just set a default value in case it's not set.
Don't use SERVER_NAME as is, you need to add some form of validation, make an array of acceptable values for security. |
Welcome Guest, Not a member yet? Register Sign In |