Archive for the ‘PHP Frameworks’ Category

Laravel .htaccess localhost MAMP and Mac OS X

I was, like anyone, excited about the release of Laravel 4 and quickly set about following the initial installation instructions on a vanilla vhost locally to have a play around with. I quickly found that the default suggested .htaccess file was causing a server error in MAMP on OS X.

I got around it with a little trial and error and can confirm the below contents in your .htaccess file – works great for me.

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . /index.php [L]

The offending line from the suggested .htaccess contents was

RewriteRule ^ index.php [L]

Best installation guidelines for MAMP and PHPUnit

These are the best guidelines I have found and mashed together recently for installing and configuring PEAR and PHPUnit for use with MAMP.

Firstly tell PEAR to auto discover:

sudo /Applications/MAMP/bin/php/php5.4.4/bin/pear config-set auto_discover 1

Secondly install the PHPUnit PEAR package:

sudo /Applications/MAMP/bin/php/php5.4.4/bin/pear install pear.phpunit.de/PHPUnit

Thirdly link it to your profile:

sudo ln -s /Applications/MAMP/bin/php/php5.4.4/bin/phpunit /usr/local/bin/phpunit

Lastly test it:

phpunit --version

Should output:
PHPUnit 3.7.10 by Sebastian Bergmann.

All done!

Laravel and WordPress as a subfolder

I wanted to recreate a small blog for a site I was building in Laravel for a bit of fun but didn’t want to waste/spend loads of time recreating a blog. When in my honest opinion WordPress does an un-touchably good job of that already.

If you want to just simply install WordPress in your Laravel install under a subfolder, it’s quite simple really. Just install into public/blog (or whatever you want to name your blog).

Mac terminal fan? Little SVN one liner for you.

cd public | mkdir blog && cd blog | svn co http://core.svn.wordpress.org/tags/3.5 .

If you don’t use the public folder as your vhosts root like me you could use a .htaccess rule instead.

# Apache configuration file
# http://httpd.apache.org/docs/2.2/mod/quickreference.html
# Note: ".htaccess" files are an overhead for each request. This logic should
# be placed in your Apache config whenever possible.
# http://httpd.apache.org/docs/2.2/howto/htaccess.html
# Turning on the rewrite engine is necessary for the following rules and
# features. "+FollowSymLinks" must be enabled for this to work symbolically.
<IfModule mod_rewrite.c>
	Options +FollowSymLinks
	RewriteEngine On
</IfModule>
# For all files not found in the file system, reroute the request to the
# "index.php" front controller, keeping the query string intact
<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{REQUEST_URI} !^public
    RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

Maybe something like that might help? But don’t hold me to it. You could also use a exclusion rule in your .htaccess file.

RewriteCond %{REQUEST_URI} !^/(~blog|/.*)$

Opening Up For Advice

Over the last year I’ve been constantly if not more than constantly trying to ask myself, are we doing things the right way?

There are a million and one different ways to accomplish some of the tasks we undertake on a day to day basis.

Preferences are always going to change and perhaps there is not one best method of practise at all.

Im trying to open myself up here to ask anyone in the context of my company and I, what the next step could be.

We build lots of text based games, driven by simple php and mysql, php = mixture of functions and classes. I generally don’t like the idea of php frameworks for use with game design of this type, as games quickly grow code base hugely and you get the annoyingness of extra overheads in load time. However im very much open to new ideas as to how we could improve code. Maybe a new language, or maybe a different approach.

I wondered really if anyone out there has built a complex game on anything other than there own custom php code and mysql (obviously in the context of text based, browser based games and improving on php).

Also we do alot of client work, nice designs, baskets and checkouts all the usual stuff. Does anyone use a particular framework for similar things and found its really good? We spend far too much time repetitively coding things like checkouts and baskets for each customer.

Ideally its all about taking things up a notch and what could improve what we do.

I’d also like to know if anyone uses any particularly good checkout bundles or companies, to manage all there payments really easily. Ours is very disjointed atm. With payments for different sources ie mobile, card etc all being taken by different companies.

PHP frameworks CodeIgniter, Zend & Symfony

Lately I have been considering PHP frameworks and using them to speed up development of small projects, whilst also considering the MVC (Model, View, Control) approach. Most people looking for a PHP framework seem to stick with CodeIgniter, Zend or Symfony. Each with there own advantages and disadvantages. Which one is best is all down to personal taste and its very difficult to make an educated selection of the framework thats best for you. Its baffled me infact, that I can’t put my finger on the framework that I think works for me the best.

So I plan to try and develop a small project in each of these frameworks and decide after that which one I think is the best for me.

For more complex sites, I will continue to use my own custom framework as it helps to keep down page load speeds and ease of understanding.

Check back here over the next month or so, to see what I get up too. As I will be posting all about my experiences with the frameworks.