As I wrote in the previous post, the problem with defining the base_url variable is quite annoying. Specifically, this variable takes care of creating the path to the links, the action in the forms, redirects and so on and if it is not the last CI does not work correctly 🙂 It works but does some crazy things with urls 🙂 The solution as always is simple ( it appeared for me shortly before I decided to write it myself) 😀

$config['base_url'] = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "https" : "http");
$config['base_url'] .= "://".$_SERVER['HTTP_HOST'];
$config['base_url'] .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);

This piece of code replaces base_url in the configuration file. Works as seen for both http and https. It only takes the folder in which the platform is located like this, that no intervention is needed on our part.

My life as a programmer has changed dramatically – I reached for those fruits that I had always disliked – ready framework for project coding, the reasons are purely mine why he doesn't like them. But I was left without a choice and turned to friends with experience in the field and they directed me to CodeIgniter I basically reviewed what he was talking about – I liked it. Apart from the fact that I read quite good reviews, so there was no point in avoiding the inevitable. Today I started writing with the platform and found out 2 very unpleasant things

  1. Error reporting is only for file logs and the platform does not spit errors directly on the page – only one white page appears and you wonder what is happening. Insanely inconvenient Even after manual adjustment in php.ini things remained in favor of CI. The solution to the problem is to add an external helper Err Helper – the man explained how to sail this miracle. After I put it on, everything fell into place.
  2. In the configuration file of the platform there is a variable base_url in which the main URL is described so that the platform can complete links, redirects and any other URLs. – overall the idea is good but if the site is more than 1 domain what we do 😀 There are quite a few solutions to the problem. I will probably check with a series of ifs which domain my request comes from before I find the variable 🙂 ,because it does not want to accept a value of $ _SERVER[PHP_SELF] again a crazy decision

Excluding my two remarks, I like CI, it's easy to run a server, even an inexperienced 9th grader will do it and not like Zend Framework to ask for hours of tuning 🙂 let's see if we will hold hands or become a part of the past 🙂