Yii2 Framework

So tasked with updating an existing PHP app I chose to use the very powerful and often under rated Yii Framework. Let me say for the record, it has been an absolute pleasure to develop with and its blazing fast. Sure there are some nuances to learn, like all the config items are in arrays, but thats not different from other frameworks except that with Yii there are so many options it can get tricky to maintain.

Bu you really deal with config array for very short periods of time and then you move onto building your app. I found GII the GUI based code generator to be extremely powerful and it has done like 80% of the heavy lifting for me. I generate for example all the CRUD code I need and then I change and re-structure as I see fit. In addition to that the performance is stellar.

Certainly checkout this awesome framework, especially if you want to get things done very quickly or you need to prototype an app.

Yii Framework

Better still if you need an app done quickly drop me a note.

Regards,
Brendan

.NET Core Rocks

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’m excited.

Peace,
Brendan

A better autoloader

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
*/
function __autoloader($class_name)
{

//class directories
$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
return;
}
}

}

spl_autoload_register(‘__autoloader’);

 

Ajax on Steriods in CodeIgniter

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…

https://github.com/IgnitedCoder/ci_pheryphp

Code on!

Brendan

Meditation: This code is pissing me off.

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.