OverviewObjectiveLearn how to build a basic applications. Includes a tutorial onbuilding a LinkedIn Application.Requirements Installed version of ProdigyView with a database Understanding of how to install an application Understanding of the DEFINESEstimated Time12 minutes www.prodigyview.com
Follow Along With Code Example1. Download a copy of the example code at www.prodigyview.com/source.2. Install the system in an environment you feel comfortable testing in.3. Proceed to apps/front/HelloWorld/HelloWorld.php www.prodigyview.com
Starts with PV_EXECApplications are called with pv_exec. The application’saccess file will be included and a new instance made.This tutorial is going to start building the application bycreating the access file. The access file is defined wheninstalling the application.If you are unsure of how toinstall an application, read the tutorial on installing anapplication. Singe Point of Entry
Command Interpreter The beginning of our commandInterpreter should look something like this:1. Class Name 2. Constructor(optional) 3. Command Interpreter(required)We simply define the class, a constructor and acommandInterpreter method.
Inside the InterpreterThe required function is the commandInterpreter. It will controlhow your application responds to calls made by the user or otherapplications. Below is the logic for our commandInterpreter inthis example.
Break Down 1. If no command was passed, get the command from $_GET 2.If the command is hijudy or hellojudy, call the method sayHiToJudy() 3. If no command matches, call the main function
Application BodyOutside the commandInterpeter, we have the application bodywith our functions to execute.
Application Body CompleteOur application body should look like this. Next we are going to start executing commands.
Private/Protected FunctionIf you noticed in the body of the application, all themethods were private except for the default method. Oneability of the application is make all the methods private orprotected and only allow access to that applicationthrough the commandInterpreter.This can be considered a form of access control for yourapplication.
Switch DocumentsNow that we have the application built, we can call it.Switch to HelloWorldTest.php to test it out.
Call Our ApplicationMake sure the application is installed first. Then throughpv_exec, we can call the application that was built.1. The application unique id 2. Commands to execute 3. Arguments passed to the application
Automatic CommandInterpeterThere is an easier path to implementing an commandInterpreter. First start by reviewing the tutorial on the chain ofcommand command design pattern. Now we are going toswitch examples and view our LinkedIn application.
Extending PVApplicationJust like in the tutorial on the chain of command designpattern, we are going to extend PVApplication. ThePVApplication will implement the commandInterpreter withoutthe developer having to define it.Using PVApplication, the command will actually become thename of the function to be called.
Application LayoutOur application extending PVApplication then look like this, nocommandInterpreter. All that has to be done is called pv_exec.
Switch DocumentsAgain, switch back to HelloWorldTest.php file and headtowards the bottom of it.
Calling our Application Now execute our LinkedIn application. It will display the share button for LinkedIn.1. Application unique id 2. Command to execute
API ReferenceFor a better understanding of the applications, visit the apiby clicking on the link below.PVApplications More TutorialsFor more tutorials, please visit:http://www.prodigyview.com/tutorials www.prodigyview.com