Wednesday, April 30, 2014

Drupal Services Views - Unformatted List Display Format

Services views module empowers developers to expose their views(queried data) as web service endpoints for GET requests. When creating the view, however, the Unformatted List display format can create a nightmare for the developer.
The reason is selecting Unformatted List with teasers and full posts selected creates an unfriendly endpoint data structure which won't change even if the user changes the Display Format to Table or anything else in the view editing screen.
To be on the safer side selecting Unformatted List should always go with selecting titles, titles(linked) or fields instead of the teasers or full posts.
 One might ask what if the developer wants comments related to the post in the data? Well it is simpler and best to create a view for comments with the node id (Nid) as an exposed filter so that the app makes that request separately from the request to the node itself.
So http://host/apimachinename/views/viewsmachinename?nid=nodeID will give you comments related to the post which is fine.




Thursday, April 24, 2014

Drupal - Creating an API without losing your soul.

Drupal services https://drupal.org/project/services is a one stock module for exposing every aspect of a drupal site's functionality as a service for multiple device consumption.
Services views module https://drupal.org/project/services_views enables site builders to expose their views (Drupal query builder) as a service making a developer build an entire API without writing a single line of code. If a developer wants custom service endpoints, they just create a module and use hook_services_resources() to get that endpoint up.
Other devices can now make requests and push content or fetch content to the API. All the authentication methods are also supported. Session authentication exists by default but turned off. A developer can enable that or use http basic authentication https://drupal.org/project/services_basic_auth or Oauth authentication https://drupal.org/project/oauth .

"Lazy Development" - Java, .NET, and PHP

Microsoft started the process of making developers click around to get things done with their superb IDE. An idea which was frowned upon by coding junkies because they think software development should always be rocket surgery. Java IDEs had no option than follow the trend with NetBeans and JDeveloper Studio (the ones I have been using). The multipurpose Dreamweaver is also good but have been overshadowed by the other specialized IDEs. In the PHP arena Drupal is the only software I have seen and used which comes close to letting PHP developers develop with ease the way .NET and Java developers develop do with their IDEs.
Drupal is a monstrous sort of software. It is more developer friendlier than non-developer friendly. It treats every content as an organized entity so that specific parts of the content can be displayed when the need arises. Unlike other CMSes which let users just dump content here and there once they have it. If someone has used the non-developer friendly Wordpress and Joomla CMSes before and they come to Drupal, they find themselves in a maze.
Whenever I am building complex web apps, my go to software is Drupal. If is it not complex enough then Joomla all the way. It is all about using the right tool for the right job.
I will go through a lot of hell if I were to use Joomla or Wordpress to build APIs for multiple devices consumption.  I mean native apps consuming content, not just device browsers consuming content or responsive web. Using Drupal for such a task is super easy since version 5 and the next version of Drupal, 8, comes with this functionality in core. One doesn't have to install module before they can expose content as a service for multiple devices to consume.
.NET and Java developers can easily build APIs fast by clicking around again in the IDE's specified above.

Wednesday, March 27, 2013

Handling "Fatal error: Maximum execution time of 30 seconds exceeded" in PhpMyadmin

Phpmyadmin caches pages and if one encounter the "Fatal error: Maximum execution time of 30 seconds exceeded" on a page, that page will be shown every time they click on that url. Apache restart or quitting all services and shutting down wamp or xamp won't solve the issue.
The solution
  1. Open that link in a new tab.(You will see the page with the error)
  2. Change the token value in the navigation textfield. You will see something like token=8318feae751e3db846d6a703cf6bc757  change just one of the token characters example 8318feae751e3db846d6a703cf6bc757 changes to 8318feae751e3db846d6a703cf6bc758
  3. Press the enter key
With this done you can get access to the page and do your stuff.

Sunday, February 3, 2013

The extinction of syntax errors.

IDEs have done a great deal in making syntax errors in applications a thing of the past. Unless someone has got the time to code in non-syntax error highlighting editors, they will encounter syntax errors only when they are typing codes, not when the application build is complete.
21st century coders think of application logic so whenever they have a bug to deal with, it is more of a logical error.
IDEs like the OutSystems Agile Platform Studio http://www.outsystems.com/ take application logic to another level by letting the developer create application logic flow as flowcharts. No coding required.


Monday, January 28, 2013

Write Once, Run Anywhere Mobile Apps

Thinking of developing apps for iPhone and getting stuck because of Apple's buy-a-Mac-before-you-can-develop-for-our-iDevices policy? Relax. Enter codenameone . You write your mobile application in Java and deploy to iPhone/iPad, Android, Blackberry, Windows Phone and J2ME.
What is the catch here. True native applications with lightning speed performance not HTML5 apps. Check out these links to see for yourself why facebook dumped their HTML5 apps for Android and iPhone and went back to native
Facebook doubles iPhone app speed by dumping HTML5 for native code
Facebook Android app drops HTML5 and rolls out rebuilt native app
Codename Designer lets developers create their GUIs faster. Coding logic of the the apps is truly fun. The coding style takes the pain in coding out for developers to write apps with the minimum lines of codes possible.
Have an mobile app idea? Just use Codenameone to develop it because it rocks.

Tuesday, February 14, 2012

Handling PHP Warning: Cannot modify header information - headers already sent

This can be a nightmare for a developer if they want things done quick. It is caused when a page/file which has already been requested get requested (require_once, require, include) again in the same script.
At times a developer need to get the thing to work at all costs and the only way to achieve is code hack. Simply tell PHP to keep its warning off just before the include or require statement and its warning on after it.
For instance I am requiring a file named cannotmodiy.php and the error occurs. The solution is
<?php

error_reporting(0);
require_once 'cannotmodify.php';
error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING);
// other codes continue

?>
So you tell php, hey! I know what I am doing. Keep your mouth shut. Then after that you tell php to speak of any errors it sees. As simple as that.