Tag Archives: PHP

Flex – Cairngorm Architecture Overview

Cairngorm is the lightweight micro-architecture for Rich Internet Applications built in Flex or AIR. A collaboration of recognized design patterns, Cairngorm exemplifies and encourages best-practices for RIA development advocated by Adobe Consulting, encourages best-practice leverage of the underlying Flex framework, while making it easier for medium to large teams of software engineers deliver medium to large scale, mission-critical Rich Internet Applications.

Cairngorm Architectural Framework

Cairngorm follows the principle of separating the view and business logic which is known as the Model-View-Controller pattern (MVC). The following list shows the different elements that form the framework.

1. View: Contains UI controls for user interaction and displays the state of the models data. Views dispatch events handled by the controller.

2. Model Locator: It acts as a centralized repository for all data needed in the application. It manages the view an is declared as [Bindable] to use all variables for data binding in the view. It must be implemented as a singleton which implements the Cairngorm IModelLocator. All data managed in the model should only be updated through a command or a responder object.

3. Value Object (VO): A value object is a class that only has properties to store values. It contains no methods or logic and acts as a pure data container. Value objects must implement the Cairngorm ValueObject interface. If they should be mapped to a corresponding server-side class it must declare the [RemoteClass (alias=”)] metatag. By doing so, Flex automatically converts an server-side object returned through remoting or data service interaction to its corresponding ActionScript object.

4. Event: In Cairngorm everything should be mapped to an event. Whenever the user interacts with the view or an action occurs an event must be dispatched. Custom events extend the CairngormEvent class an have a special property to contain the data that comes with it.

5. Command: Commands actually do the majority of an applications work. They recieve the event and its data, execute the logic an can change the workflow state of the model and view. Each command must implement the Cairngorm ICommand interface and its execute function. The revcieved event is a generic CairngormEvent and must be casted to the appropriate custom event first. The complete frontend-logic of the RIA is encapsulated within the commands.

6. Front Controller: It extends the Cairngorm FrontController class and maps the dispatched events to its corresponding commands. Therefore it has two methods: the constructor and an initialize method which will map an event to an command via the addCommand method. The controller is instantiated directly in the main.mxml via a component tag. You simply need to add the directory your class is in as an XML Namespace and then include the tag in the file.

7. Service Locator: Implemented as a singleton, it contains references to all services an application will use. Like the Front Controller, it is placed within the main.mxml via a tag. Possible services to be used are RemoteObjects, HTTPServices, WebServices or custom services.

8. Business Delegate: Business Delegates form an abstraction layer between the server-side services and the main frontend application. The locate the required service in the Service Locator, call the given method on it and route the response back to a responder object. Unlike the other elemente in the Cairngorm architecture, it does not extend a class or implement an interface, but it need to follow some guidelines: it must have at least two properties, one named reference to the ServiceLocator and one reference to a responder, both set in the constructor. And it must have implemented one method for each server-side method to be called. The delegate is created within a command object. It should only pass strongly typed value objects to a responder. If it does not recieve an appropriate object, it must create one before passing it.

9. Responder: Responders implement the mx.rpc.IResponder interface. A responder recieves the result of a service call and implements frontend-logic like a command. It directly may set values of the model and should only deal with strongly typed value objects.

10. Service: The Service is formed by an application tier, build with some server-side technology like J2EE or PHP. It Accepts the service requests from the RIA and responds back data. With a remoting technology like BlazeDS it is even possible to pass back value objects witch are transformed to their corresponding ActionScript objects in the application, so it can interact with them as if they are created by script.

20 open source shopping carts

Use any of these 20 open source shopping carts to maximize your sales potential. Some of these aren’t open source, but they are all free. Create an online store and increase your revenue.

1. WP e-Commerce at Instinct Entertainment
WP e-Commerce is a very powerful e-commerce cart for WordPress. It uses your WordPress database to keep track of customers. You can do pretty much anything you can with other carts, while integrating with WordPress.

2. CubeCart
This shopping cart is very popular. It’s entirely free for version 3, with the exception that you leave their copyright notice in your footer. CubeCart has a large amount of payment gateways (Google Checkout, Paypal) and a very active community. Their support forums are lively and many people contribute plugins to the cart. Version 4 is pay-only, but has SEO out of the box.

3. Magento
Magento is currently in beta (it’s only up to version 0.6!) but is already shaping up to be one of the best e-commerce carts out there. Magento features clean urls and SEO from the start. Everything is designed in a clean and simple way. The code it outputs is semantic, which is very rare for e-commerce carts, even commercial ones.

4. osCommerce Online Merchant
osCommerce is a very popular online shopping cart. osCommerce supports multiple currencies, allows customers to print invoices from the order screen, and has an easy database backup system. Transactions are also carried out in SSL, making them more secure.

5. osCMax
osCMax is a branch of osCommerce. It gives you unlimited products and categories, multiple payment gateways, multiple shipping gateways and separate customer groups. Because osCMax is so similar to osCommerce, you can use many of the plugins that were made for osCommerce inside osCMax.

6. OpenCart
OpenCart feels lightweight but is full of great features. The backend is very simple to use. On really great feature is that customers can write their own reviews of the products listed. The latest version has also moved towards xhtml/css for the frontend.

7. Zen Cart
Zen Cart has been around for a while and recently moved to xhtml for templates. Zen Cart also supports multiple payment and shipping options, quantity discounts and coupons. The support forums are very active and most people on them are friendly and helpful. The newest version has added support for PayPal Express Checkout.

8. cpCommerce
cpCommerce is an easy to customize shopping cart. It’s template based so you never have to edit more than 5 files to change its look. You can view your store’s history, specify manufacturers and hold sales.

9. Digistore Free Ecommerce
Do you like a lot of options with your ecommerce carts? Good, because Digistore allows you to run your store in SSL, have express checkout, let guests check out without registering and more. Digistore supports Authorize.net and PayPal for checkout.

10. VirtueMart
VirtueMart is a free ecommerce web design plugin for both Joomla and Mambo. It can be used to display a catalog, or can be used as a full fledged shopping cart. You can assign products to multiple categories, sell downloadable goods and notify customers when an out of stock item is back in stock.

11. Boss Cart
Boss Cart is a fairly new shopping cart. It has support for PayPal gateways, it’s template driven, it has search engine friendly pages and is easy to set up. You can even embed flash movies in product pages. Work on version 2.0 has recently started too.

12. PHP Shop
PHP Shop is an ecommerce cart built on PHP. It uses CSS-based themes so it is very easy to customize. The product descriptions are edited with a WYSIWYG editor. PHP Shop supports SSL and can process credit cards live, depending on the payment gateway.

13. PayPal Shopping Cart
Did you know that PayPal offers a shopping cart that can be integrated with your current site? There is no cost for setting this up and it allows you to process credit cards and bank account payments immediately.

14. BakeSale – Simply Shopping Cart
BakeSale is quite a unique shopping cart. It is a “no-frills-get-only-what-you-need-and-nothing-more” cart. There are no ratings for products and no customer reviews. This also means that there is not bloat. You use the cart for one purpose only, to sell your products to a person who wants to buy them.

15. Mal’s e-commerce
This is a full featured ecommerce shopping cart completely free of charge. The only thing not included is credit card processing. Credit cards must be processed manually or you can buy a third-party payment gateway. It does support PayPal however.

16. Ubercart
Ubercart is a full featured ecommerce cart add-on for Drupal. It features single page checkout, anonymous checkout and integrated payment systems for multiple payment gateways. Ubercart is PayPal certified.

17. Fat Free Cart
Fat Free Cart is the simplest shopping cart I have ever seen. All you do is copy and paste some code and viola! You have a store on your website. Checking out is handled by either Paypal or Google Checkout. You do not have to sign up for this code, you simply copy and paste it.

18. AgoraCart
AgoraCart is a very popular online shopping cart. It features a css manager so you can edit the look of your cart online, unlimited product options, up to 4 different tax zones at the same time, lots of shipping options and tons of payment gateways. AgoraCart gives you many options for your store.

19. Cart97
Cart97 has a lot of great features. It’s easy to set up and very, very easy to run. Customers can submit reviews, when viewing item details it suggests other items for sale, it supports wishlists and even has sale options. The item detail pages work similar to Amazon so customers feel comfortable shopping. The only downside is that it isn’t the easiest cart to customize.

20. storesprite
storesprite’s motto is “free certainly does not mean basic”. Their cart has many features including automatic tax calculation, automatic delivery cost calculations, customer ratings and reviews and featured products. That backend panel is designed to be easy to use, even for someone who has never worked with ecommerce before.

PHP vs Ruby

Both PHP and Ruby are scripting languages used to develop web applications. There is a little difference between these two languages.

Pitfalls of Ruby:

  1. Slower: Ruby is noticeably slower than other interpreted languages and has a lot of performance issues. Even classic, simple CRUD applications often discover somewhere down the line that there’s something enormously computationally intensive that they want to do, for example, blog software might want to add Bayesian filtering to eliminate spam from comments. This is where you suddenly realize that if your language of choice is 10 times slower than the competition, you may be simply unable to add that feature, or you may have to call out to another language.
  2. Hosting Issues: Rails applications are also more trouble to host than PHP applications. Because of the size of the Rails framework code, it has to be kept in memory all the time, not loaded in response to a request. You need 100–200 MB of dedicated RAM to host even a low-traffic Rails application. With PHP applications, in contrast, you can host hundreds of applications on a single server, because they don’t occupy any memory when they aren’t being accessed. Another result of these server requirements is that Ruby on Rails hosting tends to be more expensive than for other platforms and languages. If you’re in the Rails sweet spot, your application is significant enough that the incremental hosting cost is insignificant compared to the value you get from using Rails.
  3. Popularity: PHP is well established and is has a lot of IDE’s, frameworks, open source projects etc. Ruby is just starting to get into the mainstream and there are still some fundamental issues with Ruby and web development. For example, Ruby integration with APACHE is still not stable. It works, but there are some known problems and can be a hassle to set up. There is a large developer community for PHP than that of Ruby.


Ruby is a promising language, and works well for small scripts and utilities, but shouldn’t be used it large-scale applications until it is a proven technology. PHP is well established language and we see a lot of applications running successfully using PHP including many CRM’s.

We can develop the application in two different ways using PHP. We can either develop the application from scratch using Code Igniter framework, which is very much similar to Rails framework. The other way is the customization of an ecommerce product. We can select the product once we freeze the features list of the application.

Upload Via FTP – an alternative to move_uploaded_file

This is a useful function if you want to transfer files between SERVERS.

NOTE : sometimes you wish to transfer files between two servers… or if you have built a CMS and you want ot install the program on a clients server, it is advisable to transfer files by FTP rather than the move_uplaoded_file. This function accepts a parameet — location of the file

function uploadFileFTP($FileName) {
//connect to the ftp server
$conn_id = ftp_connect(FTP_SERVER_ADDRESS);

// login with username and password
$login_result = ftp_login($conn_id, FTP_USER, FTP_PASSWORD);

// check connection
if ((!$conn_id) || (!$login_result)) {
error=“FTP connection has failed!<br>Attempted to connect to “.FTP_SERVER.” for user : “.FTP_USER;

//skip these two steps if you dont want to change the working directory
ftp_chdir($conn_id, “wwwroot”);
ftp_chdir($conn_id, “my_folder”);

// upload the file
$upload = ftp_put($conn_id, $FileName, $source_file, FTP_BINARY);if (!

$upload) {
error=“FTP upload has failed!”;
} else {