 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
MaltBlue.com: Use RouteMatch in Zend Framework 2 For Easy Routing
by Chris Cornutt May 02, 2013 @ 11:14:22
In the latest to his site Matthew Setter takes a look at easy routing with RouteMatch in Zend Framework 2 applications. The RouteMatch component gives you better control over your routing and lets you define "match paths" for URL to Controller mappings.
Today using Zend Framework 2 RouteMatch, Router and Request objects, I show you an easy way to dynamically update the current route. It's almost painlessly simple. [...] Well, like most things in web application development, what starts out simply in the beginner often grows more complex over time. So too is my once simple route.
His "simple" route started getting a bit out of control when he added in some pagination to the page (and query for the path match). He wanted to figure out how to re-render data with the same filters but show the next page of data. He shows how to use the RouteMatch component to achieve just this. He creates a custom module with a "listViewToolbar" helper that lets you read the router, request and handle the parameters sent via the URL. The "invoke" method is called to render the toolbar in the page, complete with the new settings.
voice your opinion now!
routematch zendframework2 tutorial routing http toolbar pagination
PHPMaster.com: The MVC Pattern and PHP, Part 2
by Chris Cornutt March 12, 2013 @ 11:19:03
PHPMaster.com has posted the second part of their MVC series, introducing you to the Model/View/Controller design pattern. If you want to catch up, part one is here.
Welcome to part 2 of this two-part series discussing MVC and PHP, where we'll discuss some of the considerations one must make when using an MVC architecture. If you've come straight to this article without reading part 1 first, I encourage you to head back and have careful read as this one will assume that you've read and understand everything it discussed.
He talks about some of the things more involved in making a MVC framework including routing and URL formats and working with templates. Sample code is included for the route handling, model/controller relationship and view classes for the templates.
voice your opinion now!
mvc designpattern introduction tutorial model view controller routing view
Vance Lucas: Introducing Bullet The Functional PHP Micro-Framework
by Chris Cornutt December 21, 2012 @ 09:02:00
Vance Lucas has a new post to his site sharing at a project he's been working on, a micro-framework for PHP that takes a functional approach to its structure (and the structure of the apps you can make with it), Bullet.
Bullet is a new PHP micro-framework with a unique functional approach to URL routing that allows for more flexibility and requires less verbosity than the more typical full route+callback approach found in other micro-frameworks. The main problem with most micro-frameworks and even full-stack MVC frameworks that leads to code duplication is that the callback or method executed to perform the action and respond to the URL route lives fully within its own scope. This means that you are forced to repeat a lot of setup code across URL route handlers that load the same resource, authorize it, etc.
He illustrates with an example of a GET/DELETE to the same routes and having to create multiple handlers for each. He restructures this with Bullet and shows how it can nest callbacks inside of handlers to make for simpler routing. It also scopes down requests and gets more fine grained as you nest, making it easier to create reusable handlers (like in other files). If you're interested in finding out more about Bullet and its structure, you can find it in the project's main site.
voice your opinion now!
bullet microframework nested functional scope routing
PHPMaster.com: An Introduction to the Front Controller Pattern, Part 1
by Chris Cornutt July 31, 2012 @ 13:31:12
If you've done any work with PHP frameworks, the concept of a "front controller" should be a familiar one. If you haven't, the idea might be new to you and PHPMaster.com has started off a series that will introduce you to the basics of the Front Controller design pattern in a few different parts.
Some are now grumbling about newer concepts that have recently made inroads in day-to-day PHP development, saying Front Controllers are a redundant "reinvention of the wheel" which should be discarded ipso facto. [...] In this two-part article I'll be exploring in depth a couple of straightforward approaches that you might find appealing, especially if you're trying to implement an expandable front controller from scratch without sweating excessively during the process or having to cope with the burdens of a bloated framework.
This first part of the series introduces you to some of the basic concepts of routing and URL handling and shares the code for a basic front controller. It parses the URL and sets up the controller and action to hand the request off to. Also included is the contents for the .htaccess file you'll need to include to route all requests back through this controller instance.
voice your opinion now!
frontcontroller designpattern introduction routing controller action
PHPMaster.com: Web Routing in PHP with Aura.Router
by Chris Cornutt June 18, 2012 @ 08:19:16
On PHPMaster.com today there's a new tutorial showing how to route your web requests with the Aura.Router component from the AuraPHP component framework.
Everyone is interested in SEO-friendly, REST-style URLs. Apache can do URL routing via mod_rewrite rules, but it's hard and error prone. Why not use PHP itself to handle routing instead? Aura is a independent collection of libraries for PHP 5.4 brought to you by Paul M Jones. Here we are going to introduce you Aura.Router. Aura.Router is a simple and easy web routing library for PHP. In this article you will learn how to create routes which are SEO-friendly, REST-style URLs with the help of PHP.
He walks you through the download and install of the Aura.Router component (separate from the framework) and how to set up the mod_rewrite rules to work with it and a front controller. He includes some code for a basic usage, showing the mapping of a default route and more complex routes with named parameters. He also shows how to use the "match" method to find the route that was matched and how to dispatch/hand off the routing to a controller.
voice your opinion now!
aura router component tutorial routing framework
Lukas Smith's Blog: Query parameter handling in Symfony2
by Chris Cornutt May 14, 2012 @ 11:56:37
Lukas Smith is looking for feedback about a question that's been in his mind a lot lately - can the handling of query parameters be made better for the Symfony2 framework (and even easier to use).
Obviously you can already access query parameters today already but it could be easier. Essentially what I want is a way for developers to easily configure what query parameters they expect and what values they expect. This is useful for several things like easier reading and validating of query parameters, self documenting API both for API docs for humans but also for machines.
He's asking for feedback and ideas from the community on a proposed solution that could make things more flexible. He also briefly mentions the route matching and how qurey parameters could cause them not to match:
For one I don't think that a mismatch on a route requirement of a query parameter cause the route to not match. However then it can quickly become confusing for the end user or it would require adding more and more syntax to handle all the different cases.
voice your opinion now!
symfony2 query parameter handling solution routing match
Lorna Mitchell's Blog: Building A RESTful PHP Server Routing the Request
by Chris Cornutt January 23, 2012 @ 11:14:11
Lorna Mitchell is back with a second installment in her "Building a RESTful PHP Server" series with this new post about handling and routing the incoming requests. (You can find the first part about working with the request here)
This is the second part of a series, showing how you might write a RESTful API using PHP. This part covers the routing, autoloading, and controller code for the service, and follows on from the first installment which showed how to parse the incoming request to get all the information you need.
She shows how to grab the controller name from the incoming request (based on her previous code), create the object for it and execute the requested action name. Also included is a sample autoloader and a basic controller - a UsersController with "getAction" and "postAction"
methods for responding to GET and POST requests.
voice your opinion now!
restful server tutorial request routing controller get post action
PHPBuilder.com: Building RESTful Web Services with the Zend Framework
by Chris Cornutt November 11, 2011 @ 11:37:45
New on PHPBuilder.com today is a tutorial introducing you to web services with the Zend Framework, a guide to creating a simple RESTful service with this popular PHP framework.
Rather than attempt to build and maintain multiple versions of the Web application in order to accommodate the diverse array of challenges and advantages presented by each device type, developers are increasingly embracing a unified approach which allows them to manage a single server-side code base which communicates with multiple client-specific interfaces by way of a RESTful Web service. The Zend Framework's Zend_Rest component offers PHP developers with an incredibly straightforward approach to building RESTful Web services.
He shows how to set up some internal RESTful routing (with the help of Zend_Rest_Route) and create a simple controller that responds to several of the major HTTP request types - POST, GET, PUT, etc. In his simple example, he shows how to update a basic TODO list with a POST and the JSON response that would follow.
voice your opinion now!
restful webservice zendframework routing tutorial controller
Gonzalo Ayuso's Blog: Building a small microframework with PHP
by Chris Cornutt August 23, 2011 @ 09:48:27
In investigating microframeworks and some of the offerings out there Gonzalo Ayuso has done a little exploring of his own. He's worked up a basic microframework and shared it in a new post as a sort of academic exercise.
Nowadays microframewors are very popular. Since Blake Mizerany created Sinatra (Ruby), we have a lot of Sinatra clones in PHP world. Probably the most famous (and a really good one) is Silex. But we also have several ones, such as Limonade, GluePHP and Slim. Those frameworks are similar.
He looks at how several of these frameworks handle routing and setup, mostly using the closures/anonymous function callbacks available in PHP 5.3. His simple example framework does some basic URI handling to find the requested module, class and function (action) to call. You can even define the output format from options like json, txt, css, js and jsonp. A sample "controller" is included with a "Hello world" and there's a mention of some other options he's exploring including Twig and Assetic integration.
voice your opinion now!
microframework exercise routing callback anonymous function
|
Community Events
Don't see your event here? Let us know!
|