building an application
DESCRIPTION
Learn how to build a basic applications. Includes a tutorial on building a LinkedIn ApplicationTRANSCRIPT
Building An Application
OverviewObjective
Learn how to build a basic applications. Includes a tutorial on building a LinkedIn Application.
Requirements
Installed version of ProdigyView with a database
Understanding of how to install an application
Understanding of the DEFINES
Estimated Time
12 minuteswww.prodigyview.com
Follow Along With Code Example
1. 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’s access file will be included and a new instance made.
This tutorial is going to start building the application by creating the access file. The access file is defined when installing the application.If you are unsure of how to install an application, read the tutorial on installing an application.
Singe Point of Entry
Command InterpreterThe 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 a commandInterpreter method.
Inside the InterpreterThe required function is the commandInterpreter. It will control how your application responds to calls made by the user or other applications. Below is the logic for our commandInterpreter in this 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 body with our functions to execute.
Application Body Complete
Our application body should look like this. Next we are going to start executing commands.
Private/Protected Function
If you noticed in the body of the application, all the methods were private except for the default method. One ability of the application is make all the methods private or protected and only allow access to that application through the commandInterpreter.
This can be considered a form of access control for your application.
Switch Documents
Now 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 through pv_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 CommandInterpeter
There is an easier path to implementing an command Interpreter. First start by reviewing the tutorial on the chain of command command design pattern. Now we are going to switch examples and view our LinkedIn application.
Extending PVApplicationJust like in the tutorial on the chain of command design pattern, we are going to extend PVApplication. The PVApplication will implement the commandInterpreter without the developer having to define it.
Using PVApplication, the command will actually become the name of the function to be called.
Application LayoutOur application extending PVApplication then look like this, no commandInterpreter. All that has to be done is called pv_exec.
Switch Documents
Again, switch back to HelloWorldTest.php file and head towards 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 api by clicking on the link below.
PVApplications
www.prodigyview.com
More Tutorials
For more tutorials, please visit:
http://www.prodigyview.com/tutorials