• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How reload config file

#1
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
Reply

#2
(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.
Reply

#3
(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
Reply

#4
(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.
Reply

#5
(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
Reply

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

#7
Are you using page caching?
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#8
(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
Reply

#9
You could make your own config file and always load that one when needed.
using the config load method.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#10
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.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.