PHP Server Framework
We use PHP for the Server-side code. This PHP server is built on CodeIgniter framework and provides an initial template to help you get started working with player features.
Review the Server-Side CodeThe GitHub repository contains the PHP-based server-side code (CodeIgniter app) that you can use to run the samples. Designed to help you get up and running in very little time, the sample CodeIgniter app is already integrated with the Ooyala PHP SDK (/application/third_party/php-v2-sdk) so there is no need to add anything else. If you already have a server setup, you can adapt the code to your use. Or if you just want to run the code sample, you can clone the repository and copy it to your server. If you clone the repository to your server, you don’t need to implement the PHP framework, as we provide it as part of the code sample.
Where to Find the Code
All of the server PHP framework sample code is located in the application directory. To get to this code in our GitHub repository, use the URL: https://github.com/ooyala/code-samples/blob/master/application.The server-side files are structured as follows with the relevant server-side code highlighted:
├── application (Main folder where the CodeIgniter application lives) ... │ ├── cache (CodeIgniter cache, you don't need to worry about this) │ ├── config (Here we have all the configuration files, both for CodeIgniter and ooyala. You only need to peek at ooyala_config) │ ├── controllers (This is where the main logic lives. Here we handle routing and passing all the server data to the views) │ ├── core (CodeIgniter core. Don't touch this) │ ├── errors (CodeIgniter specific) │ ├── helpers (CodeIgniter specific) │ ├── hooks (CodeIgniter specific) │ ├── language (CodeIgniter specific) │ │ └── english (CodeIgniter specific) │ ├── libraries (Here you can define your own libraries, and here lives our ooyala.php library ) │ ├── logs (CodeIgniter specific) │ ├── models (CodeIgniter specific) │ ├── third_party (This folder holds all third-party libraries, helpers, and so forth that you bring to the application) │ │ └── php-v2-sdk (This is the Ooyala SDK for php) │ │ └── test (This is the test suite for the SDK) ... ├── system (CodeIgniter system. You don't need to review or modify this code)
About the Sample CodeIgniter Framework
As you would expect, the main logic for this sample is in the controller directory. For specific interaction with the Ooyala API you should check the ooyala.php file inside the libraries directory. Since we don't use models in this sample, the models folder only has what comes with default CodeIgniter installation.CodeIgniter is a framework in PHP designed to have as low overhead as possible. It follows an Model-View-Controller (MVC) pattern, where you pass information to the view in the following way:
CodeIgniter follows a URL path such as the following:"base/controller/view/args"
CodeIgniter urls follow a structure like the following:
Currently, this example has the following routes:
|Secure_XDR_GoogleIMA/cross_resume||Cross device resume|
|Secure_XDR_GoogleIMA/message_bus||Simple message bus handling|
|Secure_XDR_GoogleIMA/message_bus_advanced||Milestones with message bus|
|Secure_XDR_GoogleIMA/token||An example with playerToken|
|Secure_XDR_GoogleIMA/google_ima||Player with Google IMA enabled|
|Secure_XDR_GoogleIMA/multi_feature||An example that has all of the above|
|Web_example/||A simple client page that shows a video with trending and related videos|
|Web_example/mobile||The same as Web_example root but with page resizing|