Browsing posts in: Web Programming

Windows 7 + VirtualBox 4.3.16 + Laravel 4.3

So, I’ve been trying to play around with Laravel 4.3 (which some people are saying is essentially version 5) which suggests you install Vagrant and VirtualBox. But it’s turning out to be a real PITA!!!!

I installed the latest version of both Vagrant (v 1.6.5) and VirtulBox (v 4.3.16). Then I tried setting up Homestead in Laravel. Once I had it setup (or so I thought) I tried running ‘vagrant up’ in my terminal and it got stuck at the ‘Booting VM’ line. It just hangs there, no matter how long I left it (up to 15 mins at one point).

So I launch the VirtualBox (VB) GUI to see if there’s anything there that might help me. I click the Homestead box and try Settings but I get an error that another process is trying to lock it (or something to that effect). I exit VB, but when I start up Windows Task Manager I notice that VirtualBox.exe is listed several times and I can’t seem to ‘End Task’ them (similar situation to this post). After a quick Google search it is suggested that I uninstall VB and reinstall, so I try uninstalling it. But because of the few VirtualBox.exe’s still running in the background the uninstall hangs for ages. I figure the best thing to do is reboot my PC. During the shut down process it tells me that the uninstall process is stopping my computer from shutting down, so I go ahead and tell it to ‘Force Restart’. That doesn’t go well! It got to the Shutting Down screen and just hung. I eventually had to hold down my power button to shut the PC down.

After it restarted I uninstalled and reinstalled VB and tried ‘vagrant up’ again. Still no joy. This time around though I figured out that pressing CTRL+C twice in the terminal after vagrant hangs at the Booting VM line shuts the vagrant process down (although I’m not 100% sure what that does). Going back into the VB GUI still gives the lock error but this time I figured out that instead of trying to End Task VirtualBox.exe there is another process called VBOXSVC.exe which you can shut down and then restart VB and the box settings option works. When you open the box settings it’s like a diagnostic is ran automatically to check all the settings are ok. It suggested that the RAM for the Homestead box was too high  (2GB of the 4GB I had available). I tried reducing it to 1GB and then started the box again but it just hung again.

At this point I figured there must be some setting in the Homestead box that doesn’t play well with my PC, so I try adding the hashicorp/precise32 box suggested in the Vagrant docs. Still no luck. Still hangs at the Booting VM line in the terminal. Time for some more Google searches.

From what I can gather from the Google searches I might be better off trying VB v 4.3.12. I’m about to install it now. Let’s see how that turns out! Updates to follow.

Update 1: Using VirtualBox v 4.3.12 starts the hashicorp/precise32 box just fine, except it is asking me for a login that I have no idea should be.

Update 2: I removed the hashicorp/precise32 box and the laravel/Homestead box (using the VB GUI) and re-added the Homestead box (using Vagrant) and the terminal messages seemed to suggest that everything went ok (although I got 3 remote connection errrors). When I visited laravel5.app:8000 (which I set in my Homestead.yaml file) in my browser it worked! Low and behold!!! So it turns out that VB v4.3.16 was the problem all along.


WordPress + TwinHelix ‘IEPNGFIX’

If you are having trouble getting the IE PNG FIX from TwinHelix to work in your WordPress theme, make sure that you set the correct path to the .htc file in your themes stylesheet.

/* To fix IE 6 or less PNG issues */
img, div, span { behavior: url(wp-content/themes/your_theme_name/iepngfix.htc) }

If the relative path doesn’t work for you, try an absolute path instead.

/* To fix IE 6 or less PNG issues */
img, div, span { behavior: url(http://www.yourdomain.com/wp-content/themes/your_theme_name/iepngfix.htc) }

You also need to set the correct path to the image file in the .htc file.

if (typeof blankImg == 'undefined') var blankImg = 'wp-content/themes/your_theme_name/images/blank.gif';

Again, if the relative path doesn’t work, try the absolute path.

Once you have both paths set correctly everything should work fine. If you’re still having problems, chances are that the paths are still incorrect. Double check them and try again.

It took me a while to figure this out, so I hope this post saves you the bother.


CodeIgniter Profiler: Globally Enable/Disable

Here is a quick tip for users of the CodeIgniter PHP Framework (and a reminder to myself). If you wish to enable or disable the profiler globally while developing your application (as opposed to changing the value in each seperate controller), you can do the following.

1. Open the config.php file in the application/config/ folder.
2. Add a new config setting using the following code:

/*
|---------------------------------
| Globally Enable/Disable Profiler
|---------------------------------
|
| TRUE  = On
| FALSE = Off
|
*/
$config['profiler_status'] = TRUE;

3. Then in each of the controllers that you want to the profiler to be displayed on, add the following code to the constructor.

$this->output->enable_profiler($this->config->item('profiler_status'));

Note: If you prefer to only have the profiler be displayed on some methods, then place the code from step 3 above into each of the methods.

Hope  this helps :)


PHP Frameworks

Recently I’ve been toying with the idea of using a PHP framework to help with the development of my web sites. The problem is, I don’t know which one to choose :(

Some of the frameworks I’ve been looking at include:

Each has there own unique advantages, but what is the best way to decide which one suits my needs the best?


Object Oriented Programming in PHP

Object Oriented Programming is the one area of PHP programming that I’m having difficulty grasping :(

I’ve managed to come to terms with functions, regular expressions and the likes, but I just can’t seem to grasp the concept of methods, and especially stuff like passing by reference! Are there any tricks other programmers out there use?
If you know of any good books, articles or tutorials that might help me in my quest to overcome this affliction, please, please, let me know!


Pages:123