I just finished a short tutorial on ASP.NET Core 1.0 and all I can say is wow. Coming from Laravel and doing a sample project was super easy. I’m not giving up on Laravel but I can say that it would be a good deal of fun to help companies transition from their existing ASP.NET Framework apps and existing console or service apps to Linux. Imagine running a C# binary cron job with params or re-factoring an existing ASP.NET MVC app to ASP.NET Core that will run cross platform. I specifically like that I don’t need Visual Studio on my Mac via a VM. I can just use Visual Studio Code and still share my project with other developers who can open the project.json file in Visual Studio, compile and run without issue.
I’ve seen a few folks refer to an old autoload piece of code written a long time ago in a galaxy far far away. Anyway this is a newer more updated autoloader function you can add to the bottom of your config.php file.
Note the array you can use to define multiple auto-load locations so you don’t have to keep everything in core.
Stick this code at the bottom of your config.php file. Or, make a file called myautoloader.php and include it in your config.php file for a cleaner setup.
* Autoloader function
* @param $class_name
* @return void
$directories = array(
APPPATH . ‘core/’,
//add more autoloading folders here… and you’re done.
//for each directory
foreach($directories as $directory)
//see if the file exsists
if(file_exists($directory.$class_name . ‘.php’))
require_once($directory.$class_name . ‘.php’);
//only require the class once, so quit after to save effort (if you got more, then name //them something else
Sometime ago I decided to give phery-php a try. What sucked though was that it was very difficult to use in CodeIgniter and Kohana, two frameworks I had grown to love and use often. Result, a phery php library for codeigniter and a class I could use in Kohana “now retired”.
Anyway, heres a link to the CodeIgniter Library…
Meditation Time: 15 Minutes
We’ve all been there. You get your hands on a legacy piece of code or code written by someone else could’ve and should’ve been simpler but it isn’t.
When it comes to coding we’ve all gathered moss or garbage from the past that now serve as our principles and beliefs, some of these principles/beliefs have served us well, and some not so well. Your geek mind has never been given the freedom to throw out the garbage, perhaps do some house cleaning.
Given the opportunity “the geek mind” will run wild, like a horse free of its reigns, let it run free… Allow all of your past beliefs, principles and ideas to flow effortlessly through the geek mind. Your only job while this is happening is to sit back and silently observe your geek mind at work.
Become an observer of the geek mind. See the ideas, thoughts about the code, and past principles about what Is and what isn’t good code and allow it all to flow.
What to expect.
You will want to fix the code immediately, “the problem solver” will appear. Don’t act on it, simply remain as the ever present observer.
This is going to be a quick post… actually all my codeigniter related posts will be quick hints and tips to make your codeigniter development easier.
This particular tip relates to productions vs development environments. Did you know that seperating production/development environments it CI is really easy?
- Inside your application/config folder simple add 2 new folders as follows
- Grab a copy of autoload.php, database.php and email.php if you have a email config file and place them into each of the folders /production & /development respectively.
- Time to edit your index.php file in the root folder of your site.
Find the following line of code in your index.php file:
define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development');
$env = $_SERVER['HTTP_HOST'] == 'yourlocaldevdomain.dev' ? 'development' : 'production';
Voila, thats it – CI will now use either the production or development folders based on your host domain.