PHP Frameworks Suck

It’s kind of funny. After trying to understand Zend 2, I decided that I was happier with Core PHP. I noticed that anyone can pick up any framework and learn it in a few days, or even a few weeks, but to master it, you really need to spend a lot of time with it. I’ve spent 11+ years with PHP at the time of this writing. I know PHP.

Why have any framework? For most do it yourself type projects, just build a website from the ground up. You already have 4 great layers (Apache or server, MySQL or Database, PHP or backend language, and HTML, CSS, JS all in one). This looks like a LAMP stack to me. Why do I like keeping it this simple? Well, you don’t “need” anything else. Really. This is all you need to build anything. And I do mean, ANYTHING! You name your project, and i can build it.

My only caveat is jQuery. I’ve gotten used to it over the years, and in a way I wish I could go back to plain JS. I mean, for the most part, I still use JS, I just use jQuery for selectors / DOM manipulation, events, and the ever so simple to use ajax function. The main reason I use jQuery is because, otherwise, I would just write my own functions to do all these things. jQuery just makes sense to use.

My next task is to convert all my jQuery into JS at some point. Why? Because that’s what the browsers understand. The browsers don’t understand jQuery, or angular, or LESS or SASS on their own. They need pre-processors and libraries to convert all that.

This brings me to my other point. The backend should be no different. PHP is what is already installed on the server. Running PHP code in your files speaks directly to the PHP installation on Apache. You don’t need additional overhead to make things work better. Write PHP, done. You can structure your PHP in logical functions to make it work for you, such as getMeSomeData(), or renderThisHtmlBlock(). But that’s it. At its core, PHP is a great and most opened and powerful framework of all. Why add so many layers of abstraction on top of it?

My next good practice is to write MySQL directly into my php code. Why not? That’s the fastest processing you’re ever going to get without involving overhead. Use propell? Why? Just so you can stack php functions that eventually build out what you meant to say with MySQL anyway? Again, more layers of abstraction? What’s the point? Because it doesn’t “LOOK” like SQL? Is that really a valid excuse? Learn some damn MySQL like a good programmer, and remove all those PHP overhead functions to keep your site optimal.

It’s not what you use, it’s how you use it. Developers have become so lazy over the years, and no one cares about code itself. They treat it like they’re bored of it and just need to add layers of complexity.

The only thing that matters is how the client side performs. All of my projects’ pages load faster than 2 seconds, out of which most load under 1 second. In the end, that’s what matters. And, the turnaround time for most of my development is minutes, not days like most projects dependent on builds.

And I simply don’t want to discuss things like memcached, composer, ruby (for SASS), or any other dependency that’s simply not necessary. Are your websites fast? Then, that’s what matters. I worked at this one company where they would be concerned with micro optimizations such as to use array brackets instead of array_push function. At the same time, they were using propel that would run through dozens of php functions to get data, and their pages were loading in over 4 seconds, with unoptimized images, and over a hundred http requests. I just don’t understand this sort of mentality. These things should matter no matter if you are running an SEO site, or a private LAN intranet. Users will complain when your site loads in over 2 seconds. That’s a rule.

I’ve built many systems over and over and over only to come to the same conclusion. Simplicity just works better. Ask Steve Jobs.

How to Migrate a WordPress Project

When working on WordPress projects, and you need to migrate, let’s say from LOCAL to DEV, or DEV to STAGING, or STAGING to LIVE, whatever the case may be, you need to keep a lot of things in consideration.

Here’s my setup:

  • SVN holds any custom themes or plugins, not the core files, or config files.
  • Multi-tier environment with dropbox backing up local files. (LOCAL, DEV, STAGING, LIVE)
  • LAMP dev environment.

Before you migrate, setup WordPress:

  • Create an entry in the hostfile if necessary
  • Setup the vhosts file
  • Unzip WordPress in the new folder in all environments
    • public_html/newsite.com/dev
    • public_html/newsite.com/stg
    • public_html/newsite.com/www

Let’s go through the basic list:

  • Make sure core is not in SVN. Only keep changes, and new development in SVN.
  • Make a list of plugins used.
  • Extract WordPress in the folder you want to install the website.
  • Copy database to new database.
    • Change DB URL
    • 1
      UPDATE wp_options SET option_value = REPLACE (option_value,'old.domain.com','new.domain.com');
    • Typically from dev.website.com to stg.website.com for staging
    • And dev.website.com to website.com for live.
  • Copy wp-config file to new folder if settings are the same.
    • Change db login credentials.
  • Do a checkout of SVN project in doc root.
  • Re-install all plugins.
    • Configure plugins.

This should be it. I wouldn’t mind working on a custom plugin to handle all this. Maybe add some custom code to do svn updates on the other tier levels as well, so all I would have to do is click a button, and BAM, svn updates to next level.

I might even dedicate a page for this. Standby for this feature.

It’s-a me, Mario!

Since I absolutely love the Super Mario Brothers, I couldn’t bare the thought of not upgrading an old classic to the power of HTML5. Am I saying that I’ll re-create the entire game here? No… probably not. But, it’s nice to know that with today’s technology, you can come pretty darn close, and sometimes, even surprise yourself.

Taken from the basic Mario where I had a jumping block on a white background, I think you’ll find it refreshing to see Mario re-evolve in the web world, and have this game be playable on any device eventually. That’s my goal.

Successfully completed the “framework”

The reason I put it in quotes is because it’s not really a framework. It’s an open ended solution for anyone that wants a working website out of the box, ready with an admin section, credentials for admin and users, search based on parameters and zip code geo locations, and pagination.

So, basically, what inspired me to scrap what I had and redo everything from scratch, and go back to the basics was the idea of too much complexity. I was digging myself deeper and deeper into my own code, limiting myself to certain rules, when I know that PHP should never be limited to anyone’s design.

So, I came up with Clean PHP, read about it here:

http://okmaya.com/clean-php/clean-php-step-1/

This is the first time in my life that I feel reassured that I can really program, and anyone that claims that OOP belongs to web development and it’s crucial, is fooling themselves.

I have nothing against OOP in its place, like console games and desktop applications, but web dev is completely different. Apples and oranges.

Read up on the clean php pages and tell me I’m wrong. But make sure you read it first. Let’s look at it this way:

OOP for console games:

  1. Game Loads (takes some games 5 minutes to create objects in memory)
  2. Those objects are in the game for the entire life of the program, or level, that’s why you see loading bars at the start of every level.

OOP For websites:

  1. Now imagine coming to a website where you have to wait even 30 seconds for every page to load because it has to build objects. Just doesn’t make any sense.
  2. Why build objects on every page load, when all the objects are going to be gone once the page is loaded anyway?
  3. It’s like building a stock car at the start of every race only to completely take it apart at the finish line. Pointless.

Anyway, enough of my ramblings. I’m proud of the work I’ve put into this little package. I say little because at less than 80K, it kicks the crap out of any MVC OOP Framework out there.

  • Note to OOP Web Devs. Stop being lazy and learn to actually program. ;)

New look and feel

I thought I would go back to the basics. I don’t like messing around with too many templates, styles, etc. Although, if I put my mind so it, I could do some layout and design. Just checkout my video site at http://twomartinis.com. Also, http://actingshowcase.com.

Anyway, new look and feel, and I’m going to also rework the pages to give a clearer understanding of what I’m doing with this site. I’m all about keeping things simple. I believe in the KISS rule. (Keep It Simple, Stupid).

Enjoy browsing.