ASP.NET MVC vs Yii MVC

yii frameworkI wanted to create a simple web application that allows me manage the data in MySQL Database, I do not wish to waste my time on coding simple CRUD functions. I prefer to generate the codes every time i modified the database.

Been notice that ASP.NET MVC would help me to achieve that, able to find samples of running ASP.NET MVC with MySQL (By default, the codes run with MsSQL).  But in the end, i found out few issues of using it.

  1. All Visual Studio Express version does not allow 3rd party extensibility.
    Means I can’t use Entity Framework with .Net Connector by MySQL to auto generate the “Model” with Visual Studio.
    Not everyone have a Standard(Paid licence) version of Visual Studio, I’m using Visual Studio 2008 Standard for the testing above.
  2. Since I’m using Visual Studio 2008 Standard, I’m only able to use ASP.NET MVC2, which now they have launched ASP.NET MVC3 (with better features and support).
So I have to look for other alternatives, but somehow, “Yii” has been a buzzword among the company. There are even presentation and demo on how to create sites in 10mins or so.
Well, is free and there is so many Gurus around to guide me and give me crash course and all I need to do is to learn how to setup Apache & PHP on my Windows. Why not give it a try… after all, if it is PHP, there shoudn’t be a problem generating CRUD and models with MySQL.
After the completed the setup, I start to follow the quick guide on setting up Yii and guide to setup my first Yii Application. Encountered the problems bellow which took some of my time to diagnose:
  • Warning: date(): It is not safe to rely on the system’s timezone settings
    “WTF”
    was the first thing that comes on my mind, then I goggled and found out Setting timezone in your php.ini date.timezone = “UTC” to fix this.
  • CDbConnection failed to open the DB connection: could not find driver
    Again, “WTF” comes in my mind again.

    1. First, I checked if my DB connection setting was correct for Yii, and it looks good.
    2. Next, lots of google results showing “extension=php_mysql.dll was not enabled“. So I enabled it in PHP.ini, and restart the apache. But I still can’t connect my first Yii application.
    3. Dafaq~~~~ done more google and found a new word call “PDO extenstion”. So I run my personal favorite PHP code (sorry, not “hello world”), phpinfo.php page and looked for the PDO section, nothing was loaded.
      Checked with all the Yii Gurus but non of them encounter this issue, reason is they install Apache & PHP via Xampp and Wamp… :(
    4. After sometime google-ing, found out that I need to do the following chances.
      php.ini set extension_dir = “C:\webserver\php\ext”
Damn~~~~ *@#*&*&%*#&*!&$*&!@($& !!!!
And finally, my first Yii Application runs~~~ Horaay….
So the lesson learn in this experience is, all those tutorial or videos of “Creating Yii application in 10min” is for people who knows and been using PHP.
For a .NET guy like me, we’ll need more time than 10 mins to run our “First” Yii application, because we learn how to setup the server first…. So is 20 mins for to really create our “First” Yii application (if we find a video or tutorial on “setting up apache & php in 10 mins“)
Overall, Yii serve the purpose of letting me do more advance stuff instead of wasting time creating simple and boring management page for internal staff.
Next… The UI control challenge awaits me…

 

Setting up Apache & PHP on Windows the manual way.

There is quite a few easy options to run PHP in a Window OS, there is Microsoft’s IIS, Apache Friend’s Xampp, Wamp Server. Tried setting up via Xampp on my Mac, ended up with lots of confusion after skipping a lot of process.

So decided to do it the manual way, is a bit confusing to search for a tutorial on doing this.
Then comes a youtube video link shared by a PHP fan (Thanks Moh, your a life saviour).

After completed the steps, I have problem starting the Apache Services. Checked the Event Log and found “Apache error – cound not bind to address 0.0.0.:80“.

Realized that I had Microsoft IIS installed and running as well, I do not want to stop the IIS services as my main task are done in .NET. So I went to look for solutions.

I end up change the Apache Server to use a different port from a forum post, here are the steps:

  1. look for httpd.conf which is located in “conf” folder inside your Apache folder. (For my case is C:\apache\conf)
  2. Search for the words that starts with “Listen“, somewhere around line 120.
  3. Change “Listen 80” to “Listen <new port number>
  4. Save and start the Apache Services.
  5. Done

After that, I start testing my first PHP code with phpinfo() (The “Hello World” test seems to be boring for me).

My first PHP code runs and I continue on setting up Yii Framework