|
Sponsored Link
|
In my last blog post, I introduced ContractLib, a simple programming by contract library that I've created for PHP 5.3 onwards. And I promised some examples :)
Installing ContractLib
ContractLib is available from the Phix project's PEAR channel. Installing it is as easy as:
$ pear channel-discover pear.phix-project.org
$ pear install -a phix/ContractLib
At the time of writing, this will install ContractLib-2.1.0. We use semantic versioning, so these examples will continue to work with all future...
I've recently blogged about how we use Drupal as a Content Repository. I wanted to write a lessons learned follow up post to see what worked out and what we needed to adjust.Where we areWe still use Drupal as a Content Repository and just consume it's content data via webservices to let our application do the complicated rendering. We launched the external part of our content in November 2011 (see our Expat Magazine and our Country & City Guides) and the internal part in December (you need to request an...
One down-side of our framework right now is that we need to copy and paste the
code in front.php each time we create a new website. 40 lines of code is
not that much, but it would be nice if we could wrap this code into a proper
class. It would bring us better reusability and easier testing to name just
a few benefits.
If you have a closer look at the code, front.php has one input, the
Request, and one output, the Response. Our framework class will follow this
simple principle: the logic is about...
As Drupal is in the process of considering how to restructure code to best leverage the PSR-0 standard, I figured it would be wise to take a quick survey of how some other major projects organize their code bases. This is not a complete rundown of every project, simply roughly comparable notes for those areas Drupal is currently discussing. I am posting it here in the hopes that it will be useful to more than just Drupal.
Note: This is based on one evening's work of poking around. If you work with one of...
Article originally from rooJSolutions blog
One of the great things about the internet is the availability of cheap or free services online, so many clients are using gmail, dropbox, github etc. for their business operations. But all to often they forget that these services are often playing the oldest game in the technology industry. "Vendor Lock-in".While the ones I mentioned are not to bad, you can cheaply and easily rescue or backup your data to another location, or move to an alternative provider....
New in the PHP manual: a quickstart for the mysqlnd query cache plugin. PECL/mysqlnd_qc, the mysqlnd query cache plugin, is transparent and ease to use. But, how? Some pointers have been given in assorted presentations, here on my blog and in some, few examples from the manual. Fixed. You can now browse a quickstart to gain a quick overview.
Architecture and Concepts
Setup
Setting the TTL
Pattern based caching
Slam defense
Finding cache candidates
Measuring cache efficiency
Beyond TTL:...
In this recent post to his blog Stuart Herbert introduces a system he's created to handle "contracts" in PHP development - ContractLib.Programming contracts are tests around functions and methods, and they are normally used: to catch any 'bad' data that has been passed into the function or method from the caller, and to catch any 'bad' data generated by the function or method before it can be returned to the caller. These are pre-condition and post-condition tests, and they are tests that either pass or...
Dave Marshall has a new post to his blog showing one method for defending against cache stampedes from assaulting your caching servers and (possibly) bringing them down.I've recently had a problem with a rather large operation (that could probably be optimised considerably, but nevermind), where by if the cached result of the operation expired, several web server threads would attempt the operation, causing some major headaches for our database and web servers. This is something I've come across before,...
Ulf Wendel has a new post to his blog pointing out the new mysqli quickstart that's been added to the PHP manual.
New in the PHP manual: a mysqli quickstart. You are new to PHP but you know how to code, you know SQL, you know relational databases and MySQL? Then, I hope, this is for you. All you need is a quick overview on the concepts? The rest is in the reference section! Here you go.It includes sections on:
making connections
executing statements
stored procedures
multiple statements
In the sixth part of his series on creating a custom framework on top of the Symfony2 components, Fabien Potencier looks at how to improve the previous examples by swapping out the more procedural controllers with actual classes.The move is pretty straightforward and makes a lot of sense as soon as you create more pages but you might have noticed a non-desirable side-effect... The LeapYearController class is always instantiated, even if the requested URL does not match the leap_year route. This is bad...
NetTuts.com has posted a second tutorial in their series focusing on the Zend Framework today. In this latest article they focus on integrating the powerful Doctrine ORM with a Zend Framework application.Ready to take your PHP skills to the next level? In this new "From Scratch" series, we'll focus exclusively on Zend Framework, a full-stack PHP framework created by Zend Technologies. This second tutorial on our series is entitled "Models and Integrating Doctrine ORM".They continue on from their previous...
In a new post to DZone.com Giorgio Sironi talks about the "open/closed principle" in software development and shows an example based on the design of the PHPUnit_Selenium project.This article shows an example of how the application of the Open/Closed Principle improved the design of a real project, the open source library PHPUnit_Selenium. These design concepts apply to every object-oriented language, including Java, Ruby or even C++. The Open Closed Principle, part of SOLID set, states that software...
Popular posts from PHPDeveloper.org for the past week:Udemy Blog: Code Wars: PHP vs Ruby vs Python - Who Reigns Supreme [Infographic]
Sankuru Blog: A pluggable compiler and virtual machine in PHP
Chris Hartjes' Blog: Better Remote Code Development
Stoimen Popov's Blog: PHP Performance: Bitwise Division
Paul Jones' Blog: The Aura Project: Now For PHP 5.4, With Beta Releases
7php.com: Building Your PHP Geek Cred To Publicly Be An Awesome PHP Developer
Robert Basic's Blog: Creating a chat bot with PHP and...
You might think that our framework is already pretty solid and you are
probably right. But let's see how we can improve it nonetheless.
Right now, all our examples use procedural code, but remember that controllers
can be any valid PHP callbacks. Let's convert our controller to a proper
class:
class LeapYearController
{
public function indexAction($request)
{
if (is_leap_year($request-attributes-get('year'))) {
return new Response('Yep, this is a leap year!');
}
A
return new Response('Nope, this...
I've updated my relatively "vanilla" PHP 5 RPMs to 5.3.9 on oss.oracle.com/projects/php.
They are built for Oracle Linux 5.7 (and RHEL 5.7). I've included the
OCI8 extension for Oracle DB, of course. The various MySQL extension
are there and use the mysqlnd driver, so installation doesn't require
any client-side MySQL libraries. Note the PHP 5.3.9 RPMs are for
testing only. For production users I recommend Zend Server.
In this new press release Zend has announced the posting of the results from their "Zend Developer Pluse" survey - a survey taken of developers world-wide about their habits, preferences and desires.Zend Technologies addresses [the question of how a new demand for a new generation of apps] in Zend Developer Pulse, a new survey series that takes the pulse of a vibrant community of developers from around the world. The company's first developer survey conducted in late November 2011 offers insights on...
New in the PHP manual: a mysqli quickstart. You are new to PHP but you know how to code, you know SQL, you know relational databases and MySQL? Then, I hope, this is for you. All you need is a quick overview on the concepts? The rest is in the reference section! Here you go.
The quickstart contains:
Dual procedural and object-oriented interface:
something pioneerd by MySQL when PHP learned OOP at 5.0 times.
Connections: how, options, persistent/pooled connections.
Executing statements:...
In this recent post to his blog Stefan Koopmanschap shares some of the troubles (and a solution) when he was dealing with getting the Geoip PECL extension installed on his Zend Server setup in OSX.Today I needed to get a client application up and running on my local system. This application uses the Geoip PECL package, so I needed to get this up and running. This turned out to be slightly more difficult than just a PECL install, as you're missing some libraries by default, so here is my log of things to...
Fabien Potencier has posted the fifth part of his series looking at building a custom framework on top of the Symfony2 components. In this new tutorial he adds in one of the major features of any framework - the controller level.For simple pages like the ones we have created so far, that's not a problem, but if you want to add more logic, you would be forced to put the logic into the template itself, which is probably not a good idea, especially if you still have the separation of concerns principle in...
Paul Reinheimer has a recent post to his blog talking about the danger of "hooks" in your development - the functionality several frameworks and other tools come with to allow you to add functionality to the core without having to change the main source.I ran into hooks rather simultaneously with two very different frameworks: Code Igniter and Lithium. In both cases I was using a rather nifty hook to handle ensuring that users were properly authenticated and authorized before accessing a page. [...] One...
|
|