Friday, March 21, 2014

Installing MODx CMS on XAMPP

Steps to install MODx on XAMPP

  1. Download MODx Revolutions Traditional package.
  2. Unzip and extract contents into htdocs folder.
  3. Make user all the required modules are enabled and settings configured in php.ini settings (refer MODx site for requirements)
  4. Rename ht.access file to .htaccess in root, core and manager folder.
    1. Problem with windows is, files can not exist without file name. So ht.access can not be renamed using windows GUI.  Switch to command line mode and do a rename using "rename ht.access .htaccess" command.
  5. Now, browse MODx using your favorite browser.
    1. It  is common to browse to root level index.php page. When browsed to index page, you may encounter "503 Error : Could not load MODx config file" error. eg: if you have extracted contents into "modxdemo" folder, your url would be "localhost/modxdemo".
    2. Instead of navigating to "localhost/modxdemo", navigate to "setup" folder, i.e., "localhost/modxdemo/setup" and follow the setup instruction. 
      1. MODx will show a welcome message, click next.
      2. Leave the default selection of "new installation" and click next.
      3. Provide you DB type and DB connection details, click on "Test database server connection and view collations." link.
      4. If connection is successful, you will be prompted to select collation and character set for the tables.
      5. After selection , click on "Create or test selection of your database".
      6. Provide site admin details and click next.
      7. MODx displays installation summary, and may ask you to correct somethings if it is not right. If every requirement is in green, click install button.
      8. This will install MODx CMS, basically it creates all the necessary tables for content management.
      9. After installation, click next in the summary page.
      10. A final Thanking message is displayed with login button.
      11. Clicking on login button will ensure the setup directory is deleted from the root folder.
      12. Now login with admin credentials and start creating content, installing extensions and templates etc.
      13. Try navigating to root page i.e., "localhost/modxdemo" now, you'll see a blank page. Don't panic here, nothing went wrong. Blank page is displayed because no content is added yet. 
      14. Add some content to home page (Resource) from the admin panel and refresh the page.
       voila...! there you go, you see the content and your site is ready to publish contents using MODx CMS.

There are some workarounds over internet to fix "503 Error : Could not load MODx config file" error. This includes creating "config.inc.php" inside "core/config" folder. This is surely resolve 503 error but results in another error "XPODdriver_ not found", I have no idea of fixing this error by doing any workaround. Instead of getting into some cumbersome techniques and wasting time, follow the steps described above to install MODx and get it up and running smoothly.

Thursday, March 20, 2014

Open Source PHP CMS

There are plenty of CMS out there, some are paid and some are open source. In spite of dozens of framework only few are success in becoming a development choice. Here is the small list of frameworks which are popular.

Wordpress
      Wordpress has a huge developer community with plenty of documentation and tutorials available.
Provide flexibility to create any kind of site with its collection of free and paid plugins. Major drawback with wordpress is, Security issues and no direct support except user forums and community.

Joomla
     Joomla is an award-winning content management system (CMS), which enables you to build Web sites and powerful online applications.Joomla! has a long development history and a very active developer community (with over 200,000 users and contributors), so finding information and tutorials is easy.

Drupal
Drupal has a very active community, with a number of IRC channels, forums, and even face-to-face Drupal events. Drupal is used by many high-profile companies.There are more than 6,000 add-ons (“modules”) available for Drupal, making it easy to extend Drupal’s functionality to do just about anything you want. 

SilverStripe
SilverStripe is good for developers and designers who are comfortable with code. It is a flexible open source Content Management System that gives everyone involved in a web project the tools they need to do their jobs. Users can get official support from SilverStrip LTD.

Cushy CMS
It is free for unlimited users, unlimited changes, unlimited pages and unlimited sites but doesn’t let you use your own logo or your own domain name for the admin panel, or customize the admin experience. Because of the nature of CushyCMS, there are no plugins or pre-defined themes.

Concrete5
Concrete 5 comes with the tag "A CMS made for Marketing, but strong enough for Geeks!". It is  very user-friendly for non-technical users, who may be the ones managing the site’s content. According to the 2010 Open Source CMS Market Share Report, concrete5′s developer community is the fastest growing among any open source CMS.

Frog CMS
It simplifies content management by offering an elegant user interface, flexible templating per page, simple user management and permissions, as well as the tools necessary for file management. Frog CMS is a PHP version of Radiant CMS, a well known Ruby on Rails application.

MODx
MODX Revolution is the web content management system that gives you complete control over your site and content, with the flexibility and scalability to grow with your business.

List of more CMS

PHP Nuke Free
Post Nuke Free
Open Effect Free
Uber PHP CMS Free (German)
Fire Site Free
EZ Publish Free (You can pay to recieve it on a cd with documentation etc) 
Site Box Free
Bee Hive Free version and Paid version (didn't have a price)
Mambo Server Free and Paid versions
Typo3 Free (thanks mjames)
Harpia Free
PHP Portal Project Free/Pay (thanks galt)

Some more CMS

APC ActionApps - http://www.apc.org/actionapps/
Ariadne - http://www.muze.nl/ariadne/
Back-End - http://www.back-end.org
Bitflux - http://www.bitflux.ch/developer/
Bricolage - http://www.bricolage.cc/
C-Arbre - http://realink.org/c-arbre/doc/
CAMPSITE - http://www.campware.org/campsite/
Cocoon - http://xml.apache.org
Cofax - http://www.cofax.org
Coranto - http://coranto.gweilo.org/
DaCode - http://www.dacode.org
DCP-Portal - http://www.dcp-portal.com
Easy Publisher - http://www.easypublisher.com
Edit-X - http://www.edit-x.com/
Geeklog - http://www.geeklog.org
Krysalis - http://www.interakt.ro/products/Krysalis/index.php
Mambo - http://sourceforge.net/projects/mambo/
Mason - http://www.masonhq.com/
mCubes - http://www.mCubes.com/
Metadot - http://www.metadot.net
Midgard - http://www.midgard-project.org/
MMBase - http://www.mmbase.org
MySource - http://mysource.squiz.net/
N/X - http://nxwcms.sourceforge.net/
OpenACS - http://openacs.org/
OpenCMS - http://www.opencms.org
Pagetool - http://www.pagetool.org
phpCMS - http://phpcms.de/homepage/phpcms/index.htm
PHPNuke - http://www.phpnuke.org
PHProjekt - http://www.phprojekt.com/
phpSlash - http://www.phpslash.org
phpWebSite - http://phpwebsite.appstate.edu/
Redhat CCM - http://www.redhat.com/software/ccm/
Scoop - http://scoop.kur5hin.org
Slash - http://www.slashcode.com
Squishdot - http://www.squishdot.org
SSR - http://www.ssrtech.com/
TeaServlet - http://opensource.go.com/
thatware - http://www.atthat.com/
ttCMS - http://www.ttcms.com
Webgenerator-X - http://webgenerator-x.com
WebGUI - http://plainblack.com/webgui
WebMake - http://webmake.taint.org/
WebTop - http://webtop.newfangled.com
Wyona - http://www.wyona.org/
Xinity - http://www.xinity.org/
Xoops - http://xoops.sourceforge.net/
Zope - http://www.zope.org
EZ Contents - http://www.visualshapers.com
SiteWorksPro - http://www.siteworkspro.com/
VirtuaNews - http://www.virtuanews.co.uk/

Let me know if i have missed out some of your favorite CMS in this list.

Javascript array find() and forEach()

This is a interesting error i found when developing a simple feature in javascript. Requirement was very simple, loop through every object in an array and match their ids. I implemented the solution using array.find() method.

javascript array.find() takes a function as an argument and passes "element, index, array" as parameters. I thought this is very handy and can be used. I completed the feature, tested in Firefox browser. Everything worked well.

But an issue was reported saying, feature not working. Then i inspected, everything looked fine until i asked this question "which browser?" to my tester. He replied "Chrome", Ah..... gotcha!! When i tested in chrome, there was a javascript error saying no method "find()" found in object array.

After doing a little bit search and research in google, it was clear to my understanding that "find()" is supported only in Firefox, if we have to support different browser then i have to use "forEach()" method.

Interesting fact is, "forEach()" and "find()" are similar in functionality. They both have same method signatures and does same job. Below is the details of both the functions.

forEach()
 
Syntax : 
arr.forEach(callback[, thisArg])

Parameters :
callback : Function to execute for each element.
thisArg : Value to use as this when executing callback.

Usage eg :

function logArrayElements(element, index, array) {
    console.log("a[" + index + "] = " + element);
}
[2, 5, 9].forEach(logArrayElements);
// logs:
// a[0] = 2
// a[1] = 5
// a[2] = 9

find()

Syntax : 
arr.find(callback[, thisArg])

Parameters :
callback : Function to execute for each element.
thisArg : Value to use as this when executing callback.

Usage eg :

function logArrayElements(element, index, array) {
    console.log("a[" + index + "] = " + element);
}
[2, 5, 9].find(logArrayElements);
// logs:
// a[0] = 2
// a[1] = 5
// a[2] = 9

Wednesday, March 19, 2014

WCF REST Service with clean customized urls

Annoying thing with WCF service is its ".svc" extension. Most of us , developers, think of having clean neat urls like in ASP.Net MVC, while there are lot of workarounds to create custom url, here is the simple one as described in the blog

http://geekswithblogs.net/michelotti/archive/2010/08/21/restful-wcf-services-with-no-svc-file-and-no-config.aspx

Here is a overview of the article published in the above link

Building a RESTful WCF service in this way is quite easy and you don’t need rely on any item templates.  Just start with a blank asp.net web application project in Visual Studio. The web.config file is virtually empty:

     <configuration>
         <system.web>
             <compilation debug="true" targetFramework="4.0" />
         </system.web>
     </configuration>
 
Next just add a regular C# class - for this example, I call mine PersonService and it will have basic CRUD operations. Typically we create interfaces in WCF to define our ServiceContract and operations like this:
     [ServiceContract]
     interface IPersonService
     {
         [OperationContract]
         Person GetPerson(string id);
      
         [OperationContract]
         Person InsertPerson(Person person);
      
        [OperationContract]
        Person UpdatePerson(string id, Person person);
     
        [OperationContract]
        void DeletePerson(string id);
    }
Keep in mind, this step is *not* required. You *could* decorate your service class directly with these attributes and not even have the interface at all. However, in this case, it’s a nice convenience to encapsulate all the WCF attributes on the interface rather than your implementation class. The implementation of our PersonService class looks like this.

    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class PersonService : IPersonService
    {
        [WebGet(UriTemplate = "Person({id})")]
        public Person GetPerson(string id)
        {
        }
     
        [WebInvoke(UriTemplate = "Person", Method = "POST")]
        public Person InsertPerson(Person person)
        {
        }
     
        [WebInvoke(UriTemplate = "Person({id})", Method = "PUT")]
        public Person UpdatePerson(string id, Person person)
        {
        }
     
        [WebInvoke(UriTemplate = "Person({id})", Method = "DELETE")]
        public void DeletePerson(string id)
        {
        }
   }
This is just a normal C# class that implement an interface. It’s also decorated with the typical WebGet/WebInvoke attributes (in the System.ServiceModel.Web namespace) that we use for RESTful services. Also notice that 3 of the 4 methods have the same UriTemplate but they are differentiated by the HTTP method (i.e., GET/PUT/DELETE). Also notice the AspNetCompatibilityRequirements attribute – this is needed for RESTful services that are processed in the ASP.NET pipeline as described here. You also have to add this to the config file (I know, I know – I said “no config” but I meant “no ugly WCF endpoint config”!):
     <system.serviceModel>
       <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
     </system.serviceModel>
So how do we take this regular C# class and make it into a service without an *.svc file?  The System.Web.Routing infrastructure has now been incorporated into WCF 4 to make this possible.  Just add the line of code (line #5) to your global.asax:
     public class Global : System.Web.HttpApplication
     {
         protected void Application_Start(object sender, EventArgs e)
         {
             RouteTable.Routes.Add(new ServiceRoute("", new WebServiceHostFactory(), typeof(PersonService)));
         }
     }
The WebServiceHostFactory makes RESTful services possible in WCF. The first parameter of my ServiceRoute constructor is an empty string which means that my URI of my service will hang right off of the root – this get combined with the UriTemplate defined in the WebGet/WebInvoke attributes.  So to get a person from my service, a URI would look like this:  http://mydomain.com/Person(21).  If I had specified “foo” instead of an empty string in the first parameters of the ServiceRoute constructor, then my URI would look like this:  http://mydomain.cmo/foo/Person(21).
That’s it!  You now have a fully functioning RESTful WCF service that you can fully test with Fidder for all HTTP verbs.
One interesting aspect to all this is that you can do all this in MVC as well. In fact, I typically do use MVC to return JSON to views for AJAX calls in my MVC apps. However, if you were building stand-alone services for this, would MVC be easier than the example of above? Keep in mind, we could simplify the example above even further by eliminating the IPersonService interface all together. I daresay that setting up RESTful routes like the ones shown above is easier with WCF than MVC (this, coming from an “MVC guy”) because we can apply the UriTemplates directly to the methods. To accomplish the same in MVC, you have to create custom route constraints to avoid the name of the C# methods from showing up in the URL (and honoring the REST HTTP verbs).  If you are going to do this, I really like the approach shown here. It’s a cool approach, but it’s *more* work than just doing it with RESTful WCF – no svc file and no configuration.
In fact, using the WCF infrastructure gets you even more features for free.  For example, if we add 1 more line of configuration (check out line #5 below) we get a help page and automatic format selection for free! Now our entire configuration just looks like this (and still no WCF endpoint configuration needed):
     <system.serviceModel>
       <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
      <standardEndpoints>
         <webHttpEndpoint>
           <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"/>
         </webHttpEndpoint>
       </standardEndpoints>
    </system.serviceModel>
Notice all we had to do to get the help page was the request “/help”: