MainelyDesign.com Blog

Php Tagged Blog Posts

Lessons Learned: Going to Mobile Website Development

Posted on 07/08/2013 at 12:39 pm | Viewed 17,490 times | 0 comments

I've recently taken the plunge and learned about CSS Media Queries and Responsive Web Design.  We launched a new ordering site and made the whole website, including the checkout process, mobile-friendly.  It's really opened up my eyes to the possibilities of mobile web design.  I started out wondering why responsive web design was all the rage, now I prefer to order and checkout using the new Site Avenger mobile shopping templates.  It's pretty easy to retrofit with an existing Site Avenger website and all new E-Commerce websites have the option of being mobile-friendly from the start.

Making PHP File Uploads Work For Large Files

Posted on 06/18/2013 at 01:01 pm | Viewed 17,958 times | 0 comments

Get PHP File Uploads Working

The first trick to having any user contributed content these days is to get PHP File Uploads working (especially with big files).  Our configuration we use for our Wamp local development and on our Linux server is below.

When managing file uploads to a server, there seems to be a lot of confusion regarding optimized PHP settings and configuration. We have had some experience with this that we would like to share.

Speeding Up Windows 8 for Web Development (using WAMP)

Posted on 02/25/2013 at 01:33 pm | Viewed 48,189 times | 0 comments

Here is my list of optimizations and changes you can make (and I've had to make) in order to get WAMP (and CakePHP) to run faster on my Windows 8 computer.

Speed Up WAMP Web Development on Windows 8

The short list, in order of importance (stop once you are happy with your localhost web server response time and speed):

  • Get the latest version of WAMP.
    Start by downloading the latest wamp.  I used the 64 bit version.  Download WAMP here.

  • Edit your hosts file.
    Make sure it has the proper entries, and most importantly, remove the IPv6 localhost setting.  Your Windows 8 hosts file should look like this:

    127.0.0.1          localhost
    #    ::1             localhost

  • Disable IP v6
    A great tutorial can be found here.  My advice is to disable IPv6 BOTH ways- via the network adapter and via the regedit hack.

  • Edit Apahce httpd.conf
    These tweaks are supposed to speed up the lstat() system calls when reading files/scanning directories.  They are:

    EnableMMAP On
    EnableSendfile On

  • Edit PHP.ini
    Increase the real path cache size.  This helps when you have lots of files involved.

    ; Determines the size of the realpath cache to be used by PHP. This value should
    ; be increased on systems where PHP opens many files to reflect the quantity of
    ; the file operations performed.
    ; http://php.net/realpath-cache-size
    realpath_cache_size = 24M

  • CakePHP: make sure debug is off.

Avoiding Errors with Zend Lucene Search Results

Posted on 01/14/2013 at 02:34 pm | Viewed 15,846 times | 0 comments

A common, recurring headache and complaint among Zend Lucene search processing is handling the data fields in search results.

We all like to be flexible and robust in handling the results, we may want our search to return news articles, blogs or webpage content.  

Invariably,  we run into problems, usually in the form of an exception

Integration of Cakephp Internationalization and GIT

Posted on 12/28/2012 at 12:33 pm | Viewed 20,992 times | 0 comments

We have discovered in a recent implementation of Internationalization that GIT can corrupt the POEdit generated *.po and *.mo files.

Upon committing updated files GIT by default will replace the LF with CRLF in these files.   These files cannot be tampered with after generation,  even viewing the files with most windows based editor may corrupt them. 

CakePHP Form Security Blackhole on Large Forms

Posted on 06/28/2012 at 11:11 am | Viewed 14,438 times | 0 comments

I kept getting the White Screen of Death (WSOD).  What we at Saco Design have appropriately named the behavior of the default blackhole Security Component setting.  The weird issue was that I was getting the issue only on the live server.  I had recently updated the live server's version of PHP to the latest 5.3.x release.  However, I neglected to update my local PHP version, which was still 5.3.5. 

The Funniest Error Message Ever - Thank You Eclipse

Posted on 10/18/2010 at 06:34 pm | Viewed 14,328 times | 0 comments

In a depature from my [normally] on-topic (i.e. dry) posts I had to post this error message up here. It made me laugh! I was working on the fattest CakePHP controller known to man (over 4,000 lines, I know... not skinny) when Eclipse ran into issues.  Eclipse gave a very descriptive error message, stating that it couldn't, well see for yourself:

CURL on Windows Doesn't Work in PHP 5.2.14 ISAPI

Posted on 09/07/2010 at 08:17 pm | Viewed 13,434 times | 0 comments

Just a quick post to let everyone know what I just found out- the version of CURL (php_curl.dll) that ships with PHP 5.2.14 for Windows ISAPI doesn't work!  That's right- it doesn't work.  I tried the MSI PHP installer package, manual installs, moving dll files into Windows and System32 directories all to no avail.  The culprit: a bad version of php_curl.dll (at least that's my best guess).  The other culprit: using ISAPI, but I don't have time to figure out FastCGI at this point.

Best Approach to Dynamic Javascript in CakePHP Views

Posted on 05/29/2010 at 12:36 pm | Viewed 22,794 times | 5 comments

I always knew in the back of my mind that there was a better way of creating dynamic javascript than the method I was using.  CakePHP has a great function as part of the $View controller:  $View->addScript($jscript, false) will add a script block to your template header.  This is the command I use to send javascript created in a Cake view up to the header, which is where most javascript should live.  The best approach to adding dynamic javascript to your CakePHP views is to implement PHP's output buffering, combined with $View->addScript().

Speeding Up Cakephp's ACL Component

Posted on 05/28/2010 at 12:12 pm | Viewed 17,608 times | 1 comment

I came across a posting today that changed the performance of my application tremendously and reinforced a concept I had forgotten about- mysql indices. I didn't realize my app was running slow until I implemented the mysql indexes below- no formal benchmark testing, but I would say speed improved by about 300%.  The improvement was most noticeble when you are building your ACL using the CakePHP suggested method.

Best Free Mysql Zip code Database

Posted on 04/20/2010 at 04:42 pm | Viewed 19,735 times | 0 comments

I'm sure every developer reaches a point when they will need to use a mysql database of zip codes in the United States.  Say you want to make a store locator and show how many miles a customer is from your store, or if you have some custom php logic that uses zip codes, you will inevitably need a mysql database of zipcodes. 

Controlling CakePHP Error Handling When Debug = 0

Posted on 04/19/2010 at 04:27 pm | Viewed 27,517 times | 1 comment

I finally had a client request a piece of functionality that required me to program CakePHP so I could better control the default error handling when the site is in production mode (i.e. debug is set to 0).  By default, CakePHP will throw a 404 page not found header whenever ANY errors occur on a production site with debug equal to zero.  This works great, most of the time.  But what about when you are having database connectivity issues?  Say when there are too many mysql connections to that overloaded shared hosting box?  Modifed CakePHP error handling to the rescue.

Setting Envelope-From in CakePHP's Email Component

Posted on 03/22/2010 at 05:56 pm | Viewed 17,352 times | 1 comment

I've setup a form that allows customers to sign up for an email newsletter and receive a coupon. I wanted to be able to track the bounced messages in case a legitimate customer's coupon was bounced for whatever reason. As I've learned, setting up the "return-path" for an email message isn't as simple as setting $this->Email->return = 'email@domain.com';  You have to use an as yet undocumented feature... $this->Email->additionalParams;

2 Neat Little PHP Tricks

Posted on 03/16/2010 at 04:15 pm | Viewed 12,142 times | 0 comments

In writing a function to validate bank routing numbers, I came across two simple techniques, that I know I will need to use again:

PHP Trick 1: Remove All Characters Except Numbers from a String

A simple little regex does the trick:

$routingNumber = preg_replace('[\D]', '', $routingNumber);

PHP Function to Validate Bank Routing Numbers

Posted on 03/16/2010 at 04:10 pm | Viewed 21,687 times | 0 comments

I needed to validate that a Bank Routing Number was valid, much like the algorithms out there to check if a Credit Card number is valid.  I did a little searching and didn't find a PHP function that would do the trick.  I decided to write my own, based on this javascript function, and publish it for anyone who wants to use it:

PHP Break Out of All Foreach or While Loops

Posted on 02/25/2010 at 02:44 pm | Viewed 22,940 times | 0 comments

Let's have some fun with PHP's break command... I didn't think it was possible.  I just learned (I've been programming PHP for like 7 years) that you can instruct break how many levels of nesting to break out of!  I'm not surprised that break in PHP allows you to specify the number of loops (or switch statements) to break out of, but I am surprised it took me this long to use it!

CakePHP Translate Behavior - Lessons Learned

Posted on 12/15/2009 at 08:29 am | Viewed 34,254 times | 5 comments

I've been working on setting up a multi-lingual web site for one of my clients.  I was excited at the opportunity to finally use CakePHP's built-in internationalization and locale functions.  However, I ran into some issues that I'm sure other newbies to internationaliztion will run into as well.  Here's some take-backs of what I learned while using the Translate Behavior in Cake...

Invalid Date Value Error in MySQL

Posted on 09/09/2009 at 02:26 pm | Viewed 12,311 times | 0 comments

I ran into an interesting issue with valid dates and MySQL on Windows.  I wrote a CakePHP import function that basically moves MySQL data from one DB to the other.  I never thought that I would see an error related to an invalid date, but I did.

What determines if a date value is invalid (read: warning) or unacceptable (read: error)?

Cakephp's Flay Class is Amazing - Examples Included

Posted on 09/08/2009 at 09:31 pm | Viewed 13,529 times | 0 comments

If you haven't checked out CakePHP's Flay class, check it out. It's one of the best utility classes for text output in CakePHP.

I just noticed that my blog was using the same META description for all of my blog entries- not good for SEO.  Instead, I want to pull a fragment of the article copy and use that as my META description.  I currently use this convoluted way to get my summaries from the article copy, so I decided to try using the Flay class.  I've used it before but I'm glad I revisited it... it's amazing!

Using Exif in PHP on Windows

Posted on 08/28/2009 at 09:40 am | Viewed 12,255 times | 0 comments

I'm trying to use the exif functions in PHP on my Windows XP computer.  I want to read the meta data that is recorded by my digital camera (exif - exchangeable image file format).  I like the idea of storing that exif data in the database, so it's searchable. I wasn't having any luck with exif_read_data(), but finally found this posting.

Changing Filetypes Shown in SWF Upload File Browser

Posted on 08/25/2009 at 04:17 pm | Viewed 16,245 times | 0 comments

It's easy to change which file types are allowed to show up (and are displayed) when you browse for files to upload through SWF Upload.  SWF Upload makes it easy to upload multiple files in PHP.

I just had to hunt through some source files until I found this in my SWF Upload config. (goes in the new SWFUpload() function)

Displaying phpinfo() without CSS styles

Posted on 06/09/2009 at 10:18 am | Viewed 22,732 times | 1 comment

I wanted logged in users to be able to see the output from phpinfo(); within Site Avenger.  The problem with using phpinfo() is that it outputs a full HTML page, CSS styles and all.  In the past this has been fine, but now I wanted to show the phpinfo() within the Site Avenger layout and CSS styles.  I came across a simple, yet highly effective solution...

Full Tag List

Meet Site Avenger - Hosted Content Management System

Powered By: Site Avenger | Site Production: Saco Design