CodeIgniter Forums
How reload config file - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: How reload config file (/showthread.php?tid=75495)

Pages: 1 2


How reload config file - omid_student - 02-12-2020

Hi
I have a script file that when i run it command line and start in loop for accept socket
There is big problem
On start script file,i load config file and i use it in this file
But when i change config file,i have to can access to new data

Example $config['title'] = 'hello';

And run php script.php and waiting...

I change title to world

But because file is running,i cannot access to new data
I try to reload with $this->load->config('my_config')
But it is unless

Please help me


RE: How reload config file - dave friend - 02-12-2020

(02-12-2020, 11:06 AM)omid_student Wrote: Hi
I have a script file that when i run it command line and start in loop for accept socket
There is big problem
On start script file,i load config file and i use it in this file
But when i change config file,i have to can access to new data

Example $config['title'] = 'hello';

And run php script.php and waiting...

I change title to world

But because file is running,i cannot access to new data
I try to reload with $this->load->config('my_config')
But it is unless

Please help me

Instead of changing the config file you can change the value of $this->config['title'] while the script is running e.g.

PHP Code:
$this->config['title'] = 'World'

Otherwise, you have to exit the script, change the config file and run the script again before the new value can be used.


RE: How reload config file - omid_student - 02-12-2020

(02-12-2020, 12:15 PM)daveĀ friend Wrote:
(02-12-2020, 11:06 AM)omid_student Wrote: Hi
I have a script file that when i run it command line and start in loop for accept socket
There is big problem
On start script file,i load config file and i use it in this file
But when i change config file,i have to can access to new data

Example $config['title'] = 'hello';

And run php script.php and waiting...

I change title to world

But because file is running,i cannot access to new data
I try to reload with $this->load->config('my_config')
But it is unless

Please help me

Instead of changing the config file you can change the value of $this->config['title'] while the script is running e.g.

PHP Code:
$this->config['title'] = 'World'

Otherwise, you have to exit the script, change the config file and run the script again before the new value can be used.

This is good when i reload page
But when config file loaded,anything changes not affect on your command


RE: How reload config file - dave friend - 02-12-2020

(02-12-2020, 01:26 PM)omid_student Wrote: This is good when i reload page
But when config file loaded,anything changes not affect on your command

That is true for changing the file, but once the file has been loaded you can change the resulting variable $this->config['name'] for immediate effect.


RE: How reload config file - omid_student - 02-13-2020

(02-12-2020, 05:02 PM)daveĀ friend Wrote:
(02-12-2020, 01:26 PM)omid_student Wrote: This is good when i reload page
But when config file loaded,anything changes not affect on your command

That is true for changing the file, but once the file has been loaded you can change the resulting variable $this->config['name'] for immediate effect.

Yes that may be but i have to reload file,because i edit config file from file manager not with coding


RE: How reload config file - omid_student - 02-14-2020

I could control my process with SIGHUP for reload files
But when i use $this->load->config('config');
New values not get
Why?


RE: How reload config file - InsiteFX - 02-14-2020

Are you using page caching?


RE: How reload config file - omid_student - 02-19-2020

(02-14-2020, 05:39 AM)InsiteFX Wrote: Are you using page caching?
No No
I try to include config file again but now working


RE: How reload config file - InsiteFX - 02-19-2020

You could make your own config file and always load that one when needed.
using the config load method.


RE: How reload config file - murugappan - 02-22-2020

I am a bit confused. I had the same trouble but when i came to think about it, i realized what i was doing is a mistake. Let me explain. The values in the config file are like constants relating to the settings. If my understanding is correct, these settings should be fixed and should put into our own config.php file. The file can be autoloaded each time. If changes are allowed to be made, then these should be loaded into a database table or json/ini files.