18
Application

Building An Application

Embed Size (px)

DESCRIPTION

Learn how to build a basic applications. Includes a tutorial on building a LinkedIn Application

Citation preview

Page 1: Building An Application

Building An Application

Page 2: 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

Page 3: Building An Application

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

Page 4: Building An Application

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

Page 5: Building An Application

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.

Page 6: Building An Application

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.

Page 7: Building An Application

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

Page 8: Building An Application

Application BodyOutside the commandInterpeter, we have the application body with our functions to execute.

Page 9: Building An Application

Application Body Complete

Our application body should look like this. Next we are going to start executing commands.

Page 10: Building An Application

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.

Page 11: Building An Application

Switch Documents

Now that we have the application built, we can call it. Switch to HelloWorldTest.php to test it out.

Page 12: Building An Application

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

Page 13: Building An 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.

Page 14: Building An 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.

Page 15: Building An Application

Application LayoutOur application extending PVApplication then look like this, no commandInterpreter. All that has to be done is called pv_exec.

Page 16: Building An Application

Switch Documents

Again, switch back to HelloWorldTest.php file and head towards the bottom of it.

Page 17: Building An Application

Calling our Application

Now execute our LinkedIn application. It will display the share button for LinkedIn.

1. Application unique id 2. Command to execute

Page 18: Building An Application

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