In this new post to the PHPInfo site, Brian Fioca takes a look at the WASP framework and how it can help you develop your applications quickly.
In this article I will demonstrate the power and simplicity of developing PHP applications using the WASP Framework through the illustration of a simple user module design pattern. The example code will encompass the creation of a user account and subsequent login validation. In the course of this discussion, we will cover the creation of the three tiers of the application- model, view, and controller-and introduce a simple approach to using AJAX to save application form data and present flexible user interfaces.
The provides the code and database structure to make the application work, including the "touch of Ajax" made using the Prototype Javascript library.
The IBM developerWorks website has a new tutorial for those looking to get into the powerful combination of Ajax and PHP - an introduction to creating Ajax-based websites with PHP.
Learn the process of writing Asynchronous JavaScript + XML (Ajax) applications using native JavaScript code and PHP. This article introduces a few different frameworks and application program interfaces (APIs) that reduce the amount of code you need to write to achieve a complete Ajax-based Web application.
They (briefly) explain what Ajax is and the benefits of it before jumping right in to a sample page. They go for the "manual first" approach so developers know to make basic connections with the XMLHttpRequest object and handle the responses. They do mention some of the libraries offered that help with the connections too (like jQuery, Prototype and Dojo).
PHPBuilder.com has continued their series looking at building an Ajax-driven shopping cart with part two posted today (part one here). Last time they laid the PHP foundation for the example app, this time they add another layer - the Ajax functionality to manage the current contents of the cart.
Finally, a link to the shopping cart is provided, although you could just as easily have displayed the cart contents on the same page. For the sake of brevity I'll just show you how to integrate the add feature, and will leave the subtraction mechanism to you as an exercise.
The Ajax frontend calls a managecart.php backend file that calls addToCart and deleteFromCart based on which type of "task" is passed to it.
On PHPBuilder.com today there's a new tutorial posted showing how to combine the Javascript power of Prototype along side PHP's adaptability to create a simple, ajax-driven shopping cart for your site.
In the latest installment of this ongoing PHP series, I'll show you how to build a shopping cart using PHP, session handling, and the Prototype JavaScript library. The cart allows users to add and delete products from the cart, as well as change cart quantities. And of course, the interaction is seemingly instantaneous, allowing for the user to continue shopping without waiting for the page to reload.
They start from the ground up - making the database tables, inserting some data - before writing up the simple PHP class with methods like deleteFromCart and getCart. This lays the foundation for the next article in the series where they add in a splash of ajax to make it a bit more user-friendly.
On the PHPRiot.com site today there's a new tutorial posted covering an alternate method for uploading files - using Ajax to help monitor the progress of the file upload.
In this article we will develop a solution that will allow users to upload a file from their computer using HTML forms. We will then determine the progress of the upload while it is in progress using Ajax, and display the status to the user.
They chose the prototype library and the APC extension for PHP to make their code work. The basic idea is, through a feature of APC, the script can receive a progress measurement back from the server. This is handed off to the Javascript (Ajax) functionality that then updates the progress meter to reflect the change.
Taking full advantage of the upcoming features in the PHP 5.3.x series (and in PHP6 for that matter), Joshua Thompson has come up with a way to accomplish some prototype-based programming in a PHP application:
With the implementation of the get_called_class() function in PHP, prototype based programming in PHP is possible. The new function is in both PHP5.3 and PHP6 snapshots. So, I went back to the drawing board and came up with a fully capable class. The $this keyword is usable, as well as being able to use the self, parent, and static (new with the late static binding patch) keywords.
Prototype-based programming is (basically) a method where classes aren't prebuilt. Instead they are created on the fly based on other objects and interfaces. Joshua's post is a huge code dump of a prototype class and an example of it in use, dynamically creating two methods and making the three objects available.
On the PHP-Learn-it.com website, there's a new tutorial today about taking those first steps into combining PHP and Ajax to make a simple working example.
This simple tutorial demonstrates how to post a form using PHP and AJAX without having to refresh the page. A first step in becoming an AJAX developer.
They chose to go with the prototype Javascript library to use its included Ajax functionality. They give the complete code first then go back and explain the different parts - how it makes the request, shows the response back from the PHp script and what the PHP script actually does.
From the PHP-Learn-It.com website, there's a quick tutorial on how to create a bit of edit in place functionality with some simple Javascript and PHP.
Suppose we have an article page on our site where people can edit articles. The article has an edit and save button which allows the user to edit the article and save the changes as necessary. View the ajax_edit_in_place demo to see what I'm talking about.
They've gone with Prototype to handle the AJAX connection and provide both the Javascript and PHP code for editing, saving and canceling an edit on the page's content.
In a previous post, Raphael Stolt showed how to create a simple application that handled the transmission of a JSON-formatted message from the Zend Framework's Zend_Service component (translating XML to JSON in the process). In this new post today he shows the other half of the equation - how to handle the JSON messages on the receiving end.
In this post I'd like to show how to unpack the JSON response and render a visual representation by utilizing the Template class of the Prototype JavaScript library.
The code is all Javascript but it's a good example of how to break down the request and output a simple list format of the contents to the page (record "shelf" and record information).
Taking into account that this pattern can be helpful in situations where a prototype object is required, along with other clones of it, in this final installment of the series I'm going to demonstrate how to use it to build a simple application for checking the validity of incoming data.
They create a simple validation system with the pattern to check and see if the inputted data is either alpha only or alpha-numeric. On top of this, they create some additional classes to check the data for things like being a valid email address or if the value is made up of all numbers.