A new feature in CakePHP 2.1 is the ability to make one view extend another view. This is a very neat feature; it's actually quite similar to the concept of Jquery templating. The concept behind it is relatively straight forward. You define one view that contains common elements that will be updated in another view. The goal is to avoid duplicating the HTML in a different view.
If you use a framework of some sort, you probably haven't thought about SQL injection for some time – in fact it almost seems dated to even discuss it. However, security should never be overlooked and it's important to not trust third party applications and people by default! So what is the best way to prevent SQL injection?
Have you noticed how I haven't specified a specific language? This is done purposely, because at the end of the day – all languages – should be able to follow this paradigm…
Well, since one of my most popular all-time blog posts is Login system with CakePHP in under 10 minutes I think it's time that I update it to version 2.x (currently 2.2 at the time of writing). The original post was probably written for version 1.2 or 1.1 and there have been several changes made, especially with breaking changes to the AuthenicateComponent.
The beautiful part is the changes are extremely limited. In fact, only the UsersController requires a few minor changes.
I have a few thoughts for some testing/comparison of mysql tables that I have been curious about. Before starting though, I thought it was prudent that I should give it some thought about the approach. The first thing that came to mind was altering the A Simple But Effective Speed Comparison code to execute a bunch of SQL queries against my local installation.
In several recent posts: It’s LEMP not LAMP! and Amazon EC2 Shoutout! I've discussed how I switched from a shared hosting account with GoDaddy to a dedicated Micro instance with Amazon. At the same time I decided to go out and try nginx (pronounced Engine-X) and remove Apache from the equation.
This saw some incredible results. However, several times since switching I've run into several database issues where it appears Mysql runs out of memory! Performing a top command shows over 15 mysql processes running at anyone giving time each taking up to 10% of the memory. On a micro instance I only get 600mb, so this adds up quickly!
Our client, Centrum Cyfrowe, a Warsaw-based NGO, is looking for a Python developer (though experience with Ruby is a plus) to help them work on, among others, a crowdsourcing project OtwarteZabytki.pl that we built for them.
More information can be found on their Facebook page and in the official press info.
Yesterday's article actually got me a little amped up about coding conventions – Comparing a while loop against a foreach loop of an array – because I never thought I would actually have to do a comparison between a while loop and a foreach loop on an array! If we go back and revisit the post, I was reviewing a recent CakePHP commit for an optimization on the Hash class. The code in question is three separate blocks of code that leverage the array_shift function to get the next value in the array with a foreach loop instead.
Are you confused by the title? I was when I first got the idea to even write this blog as well. I was recently perusing the CakePHP change logs and came across an interesting commit – Optimization for Hash Method.
The optimization is quite simple, this code:
while (($key = array_shift($parts)) !== null)
Is replaced with the following code:
foreach ($parts as $key)
In a recent blog post – It's LEMP Not LAMP – I discussed about making the switch to using NGINX (pronounced Engine-X). I had little-to-no issues getting by basic Wordpress blogs up and running. However, for some reason I couldn't get my older CakePHP sites up and working.
Here’s a snippet that is sure to be quite useful for PHP programmers and web developers who often work with XML files. It’s a code to read/write an XML file by using CakePHP. Some of you might find a few lines a bit familiar, which is because parts of it are borrowed from the concept of parsing XML.
Well – it's Friday and all of the kids are back in school. While this post is being published, I'm probably stuck in traffic! I can't believe it's a new school year already, luckily my kids aren't old enough so it's just traffic that I need to get used to.
This has been a great summer so far and I thought it would be a good idea to summarize the variety of things I've learned about – but have not necessarily blogged about…
I'm sure many of you have heard the term LAMP before – standing for Linux Apache Mysql and PHP. This is a very typical setup for many open source websites. It's been around for ages. But make way for LEMP. In a recent report by w3techs, a new HTTP server is climbing its way up the ranks called nginx, but it is pronounced Engine-X; hence, the term LEMP – standing for Linux Engine-X (nginx) Mysql and PHP.
Early work has started for CakePHP 3.0, and I’ve started re-visiting how CakePHP handles configuration and bootstrapping. I want to focus on configuration for this post, as bootstrapping, while related is worthy of its own post. The goal of this post is to provide some context on the planned changes, and to get feedback on those changes. My hope is that by getting feedback early on we can avoid problems & surprises later on.
I was previously hosting all of my sites with GoDaddy, using one of their unlimited domain hosting services. While this was pretty inexpensive compared to similar services, I was never truly happy with the load time. Often taking over 1.2 seconds to load this blog!
At my current job, I had the pleasure of doing of some speed testing with some Amazon EC2 services. I was certainly impressed with them. While I was doing some costing for work, I decided to do a bit of costing for myself. I run several websites, no hits by any means, but enough that I care about the poor performance I was getting at GoDaddy.
An interesting question was asked of me in regards to the SMACSS methodology:
Karl Tynan asked, “What do you do if you want to use the CSS from one module in another module?”
Not being able to see the design Karl was referring to, it’s hard to say exactly what I would do. However, I’m guessing one of two possible scenarios.
Two Modules with Commonalities
One would think that the purpose of modular CSS is to avoid the repetition of a batch of properties across multiple rules. After all, repetition is just another word for bloat. At least, that’s how we tend to equate the two.
Again, my mind has been to the lower dimensions of smokers' "logic".
In this post, I'm going to demonstrate a really simplistic way to improve your PHP website performance. It seems to go against the grain of "old school" vanilla PHP writing, but the results are incredible! By removing the use of require and include and replacing it with a spl_autoload_register function instead, the time savings are more than 10 times!
Not only that, in theory it's less lines of code!
If there is one thing I don't like doing – it's doing the same thing twice or even more! So I was building an application on the side where I need to have a listing that performs a simple countdown. At this point I've been lazy and just have it counting down the seconds, but this example would be really easy to update to put a proper countdown of days, hours, minutes, and seconds – and heck if you get really adventurous even weeks, months, and years!