Things I Learned Today
Uniserver on Windows REQUIRES the .htaccess file to have the “Options +ExecCGI +FollowSymLinks” line in it… Or else you get a 403 forbidden on every page you try to access.

Uniserver on Windows REQUIRES the .htaccess file to have the “Options +ExecCGI +FollowSymLinks” line in it… Or else you get a 403 forbidden on every page you try to access.

I’ve used phpMyAdmin for a while, but I find it to be a little heavyweight at times. Sometimes I just want to run a simple query. The MySQL client is obtuse to use sometimes. So I went on a search for alternatives.
I now use phpMiniAdmin almost exclusively. It’s extremely light weight, fast and has LOTS of neat features. It provides everything I need 99.9% of the time. And it’s easier to configure then phpMyAdmin.
Some say that Magento is horrible to work with. I say they are wrong. Magento is one of the most well designed pieces of software I’ve ever seen. Complete inversion of control. Awesome extendability. Sweet seperation of concerns. Proper use of classes, it’s all there.
But… It’s under documented, and it has a few core concepts you have to understand before it makes sense.
Recently I need to make a new shipping method for myhomefurniturestore.com. Fortunatly for me, magentomagick had a great article that had instructions start to finish (except for two details that are mentioned in the comments) for just such a task.
PHP Templates! Everyone wants them, some people try to provide them to others, but deep down inside, you all know smarty isn’t the way to go… Allow me to show you a better way.
Just use PHP! Yes, that’s right! PHP is almost designed from the ground up natively support templates!
Here’s the secret… When you include a php file (using the include(“somefile.php”) method, the php code inside the included file has the same variable scope as the code block that included it… So… Take the following two files….
(index.php) <?php go(); function go(){ $a = "Hi There!"; include('my_view.php'); }
(my_view.php) <html> <body> <?php echo $a; ?> </body> </html>
The output would be:
Hi There!If you’re a noob, another name for this (if you make extra effort to not put anything but loops, and echos in your template) is MVC (Model View Controller). While it isn’t a complete implementation, it’s a really really good start and makes writing and maintaining a site WAY easier. Cake PHP uses this approach for it’s views (aka templates) as well. Java uses this, but instead of the “view” using the local variables where a page is displayed, the data you want the view (or jsp page in java) to have access to are put in the request object as an “attribute”.
I, personally, put the variables I want to use in a “template” (aka “view”) in a global array ($GLOBALS['params']['name'] = “bob”;) It isn’t the best practice, because some part of your code far away could write to this and mess something up, but for simple sites, I find it quick and easy.
Of course, if you REALLY want a templating system, you could use SMARTY. (Blech!) But, I really recommend you just get used the to the echo statements and use php to render templates.
So, some sample code from a site of mine is:
<?php require_once(BASE_FS_PATH . '/classes/BookService.php'); switch($_REQUEST['action']){ case 'Research': $book = BookService::importBook($_POST['ean']); $_GLOBALS['params']['book'] = $book; include(BASE_FS_PATH . '/views/pages/research.php'); break; case 'mark_not_sellable': $book = BookService::importBook($_GET['ean']); $book->sellable = 'no'; $book->save(); $_GLOBALS['params']['msg'] = 'Book Marked As Not Sellable.'; show_details($book); break; case 'mark_not_available': $book = BookService::importBook($_GET['ean']); $book->available = 'no'; $book->save(); $_GLOBALS['params']['msg'] = 'Book Marked As Not Available.'; show_details($book); break; case 'details': $book = BookService::importBook($_GET['ean']); show_details($book); break; default: include(BASE_FS_PATH . '/views/pages/research.php'); break; } function show_details($book){ $_GLOBALS['params']['book'] = $book; include(BASE_FS_PATH . '/views/pages/details.php'); }
And the “view” for this code (details.php) is:
<body style="width:950px; margin: 0 auto; text-align: left;" class=" yui-skin-sam"> <?php include(BASE_FS_PATH . '/views/pieces/menu_and_js.php'); ?> <div style="text-align: center;"> <?php echo $_GLOBALS['params']['msg']; ?> </div> <table> <tr> <td> <h1><?php echo $_GLOBALS['params']['book']->title; ?></h2> <ul> <li>Ean: <?php echo $_GLOBALS['params']['book']->ean; ?></li> <li>Available: <?php echo $_GLOBALS['params']['book']->available; ?></li> <li>Imported: <?php echo $_GLOBALS['params']['book']->import_date; ?></li> <li>Cost: <?php echo $_GLOBALS['params']['book']->cost; ?></li> <li>Change In Inventory: <?php echo $_GLOBALS['params']['book']->change_in_inventory; ?></li> </ul> <h2>Urls</h2> (More Code That's been removed for this example)
Anyways, there are LOTs of templating engines out there you can use instead, but I would discourage it. This is the fastest, simplest, most powerful way to do templates (IMO).
I know of four different ways to do this. I’m going to cover them in the order of my personal preference (and ease).
Wamp is probably the easiest quickest way to get an apache server running PHP on your computer.
Just download the install here: Wamp Download run it, use the tool to make sure you don’t have anything running on port 80, and start the two services (apache, and mysql) by right clicking the icon in the task bar and clicking “Run All Services”
Uniform is different from WAMP and XAMP in that there is nothing to install, you just download it, and run it. This provides you with the ability to create a seperate “server” for each project you do, with it’s own mysql and apache binaries, configs, etc… I, personaly, perfer WAMP and writing all my apps to be location agnostic, so that they run anywhere and co-exist peacefully, but you may prefer this.
XAMPP is like WAMP. You download it, install it, and click go, but the only time I tried it (a few years ago) I ran into some difficulties. At the time they didn’t have a control panel like WAMP. This may in fact be the superior way to go, but I like my WAMP.
I did this once. It took me a few days (this was like 3 years ago, when my experience with PHP was ‘nill) If your a masochist this is the way to go. You’ll learn all the nitty gritties (or atleast be impeded by them). Hopefully you can beat my time.