PrizmDoc Viewer v13.9 - Updated
Legacy PHP Sample
Samples > Legacy PHP Sample

Legacy PHP Sample

Supported PHP Versions

The legacy PHP sample requires PHP version 5.4 or higher.

Linux Installation

  1. Run the "Client Installer". The installation will place the PHP samples in the following directory: /usr/share/prizm/Samples/php.
  2. Install Apache and PHP. Refer to the directions that are specific to your distribution.
  3. Add the following to the Apache configuration:

     Alias /pccis_sample /usr/share/prizm/Samples/php
     <Directory /usr/share/prizm/Samples/php>
     AllowOverride All
     Require all granted
     </Directory>
    
    
  4. On the command line, first check that the configuration file validates:

    NOTE: The command you use depends on the version of Apache you are using.

     apache2ctl configtest
    
    
  5. Then restart the Apache service to read the configuration changes:

     apache2ctl restart
    
    
  6. Give read/write permissions to the "Documents" folder, the "markup" folder and the "markupLayerRecords" folder. Give read permissions to the "imageStamp" folder. These folders are installed to: /usr/share/prizm/Samples on Linux. For more information, see the "Configuration with pcc.config" section below.

  7. Test the sample application in a browser. The following will route you directly to the Viewer sample splash page: http://myservername:port/pccis_sample/splash

Install Considerations

NOTE: With the PrizmDoc Viewer v13.6 Release, support for Ubuntu 14.04 LTS will be deprecated. With the future release of PrizmDoc Viewer v14.0, support for Ubuntu 14.04 LTS will be discontinued altogether.

Ubuntu

For Ubuntu users: In Ubuntu 13 and up, the php_curl module was unbundled from the default PHP install. This module is required by the PHP sample, and should be installed separately, as such:

Example (Ubuntu 14.04)

sudo apt-get install php5-curl

Example (Ubuntu 16.04)

sudo apt-get install php-curl

Example (Ubuntu 18.04)

sudo apt-get install php-curl

Depending on how you install PHP, you may need to install the PHP XML addition, as such:

Example (Ubuntu 16.04)

sudo apt-get install php7.0-xml

Example (Ubuntu 18.04)

sudo apt-get install php7.0-xml

Apache

Depending on how you install PHP for Apache, you may need to install the Apache PHP addition, as such:

Example (Ubuntu 14.04)

sudo apt-get install libapache2-mod-php5

Example (Ubuntu 16.04)

sudo apt-get install libapache2-mod-php

Example (Ubuntu 18.04)

sudo apt-get install libapache2-mod-php

Configure PHP Web Tier with SELinux

When running PHP Web Tier on Security-Enhanced Linux you may experience issues with loading documents in the Viewer, and may see the following errors in Apache's log files: PHP Warning: file_get_contents(<URL>): failed to open stream: Permission denied.

The Web Tier needs to contact the PrizmDoc Server but SELinux disallows Apache processes from making outbound connections by default. You can run the following command to make the Apache domain permissive and allow the Web Tier to function normally with Apache:

Example

setsebool -P httpd_can_network_connect 1

Similarly, when attempting to upload a document, the PHP application may appear unresponsive. When reviewing the document upload response in your browser’s console, you may see a 403 Forbidden error. Security-Enhanced Linux prevents the PHP / Apache HTTP application from writing to the file system by default. You can run the following command to set the httpd_sys_rw_content_t policy for the Samples directory:

Example

chcon -R -t httpd_sys_rw_content_t /usr/share/prizm/Samples/

Windows Installation

By default, the PHP sample is installed to C:\Prizm\Samples\php.

IIS

Install IIS, along with the CGI component, and then install and configure PHP. The instructions and installer provided on the IIS site are now old and outdated, as they install PHP version 5.3. Instead, install the latest version of PHP using the Web Platform Installer. If using an already configured server, make sure you are using PHP version 5.4 or higher.

To configure the sample:

  1. Note the location of the PHP sample as described above. If you changed the default install location, note the comparable sample in the install location you specified.
  2. Open the IIS Manager.
  3. In the Sites list, select the site you want to add the PHP sample to, such as "Default Web Site". Right-click on it and select "Add Virtual Directory…".
  4. In the Alias field, type the URL path you want to use for the sample. We will use pccis_sample as an example here.
  5. In the Physical Path field, use the location we noted above. Click OK to create the virtual directory.

Now you can browse to http://localhost/pccis_sample/splash in your browser to see the PHP sample.

Apache

Install Apache, or an Apache stack like XAMPP or WAMP server, and a supported version of PHP.

To configure the sample:

  1. Note the location of the PHP sample as described above. If you changed the PrizmDoc default install location, note the comparable sample in the install location you specified.
  2. Open the httpd.conf file of your Apache install.
  3. In the block starting with <IfModule alias_module>, add the following to the end of the block:

Example

# PCC PHP sample alias
 Alias /pccis_sample "C:/Prizm/Samples/php"
 <Directory "C:/Prizm/Samples/php">
 Allow from all
 Require all granted
 </Directory>

  1. Restart Apache so that it picks up the new settings.

Now you can browse to http://localhost/pccis_sample/splash in your browser to see the PHP sample.

Optional Configuration

By default, PHP has a small file size upload. If you need to be able to upload larger files through the splash page, you may need to change the following values in the php.ini file of your PHP installation:

Example

upload_max_filesize = 1000M
post_max_size = 1000M

This sets the file upload to 1GB, which should be enough to test most files through the splash page. These settings may be too high for a production service, so adjust those accordingly when deploying to production.

Configure PHP Web Tier with SELinux

When running PHP Web Tier on Security-Enhanced Linux you may experience issues with loading documents in the Viewer, and may see the following errors in Apache's log files: PHP Warning: file_get_contents(<URL>): failed to open stream: Permission denied

The reason for this is that the Web Tier needs to contact the PrizmDoc Server. By default SELinux disallows Apache processes from connecting out. You can run the following command to allow the web tier to function:

Example

setsebool -P httpd_can_network_connect 1

Browsing the Sample

From the splash page you have three options:

  1. Choice of Viewer: you can choose to load either the Full Viewer, the Book Reader, or the Comparison Viewer.

  2. Select a sample document - OR - upload a document:

    You can choose any of the 5 sample documents (Word, PDF, CAD, Tiff or JPEG). Or, you can upload a document from an arbitrary location on your computer. Note that dragging and dropping a file on this page is not supported in Internet Explorer 8.

  3. Full Viewer:

    If you select Full Viewer on the splash page, then documents will be viewed with the full-featured, out-of-the-box responsive Viewer:

  4. Book Reader:

    If you select Book Reader on the splash page, then documents will be viewed with the book reader. The book reader demonstrates how the Viewer can be heavily customized:

  5. Comparison Viewer

    NOTE: This feature requires a Microsoft Office enabled PrizmDoc License.

    If you select Comparison Viewer on the splash page, then you can upload two Word (.doc or .docx) files to be compared in the Viewer. The Comparison Viewer shows how two Word documents can be reviewed and compared using PrizmDoc:

Directory Structure

This folder contains 6 sub-folders, one folder for each of the four samples (full Viewer, book reader, e-signer and e-signer template designer) and two folders for the splash pages (main splash page and the e-sign splash page):

Each of the sample folders are completely self-contained, meaning that they contain all of the files needed to run the sample. Furthermore, with the exception of a few project files and build files, the sample folders contain only the files needed to run the sample.

Folder contents: full-viewer-sample

NOTE: The Full Viewer (with the comparisonMode configuration parameter set to true) is used for document comparison.

File / Folder Description
viewer-assets folder Contains the essential JavaScript, CSS, fonts, and images that make up the Viewer.
viewer-assets/src folder Contains Less, icons, languages, and HTML templates that can be used to build the Viewer CSS and customizations. This folder is non-essential, and does not need to be re-distributed.
viewer-assets/Gulpfile.js Contains Gulp tasks to build the Viewer Less, icons, and HTML templates. This file is non-essential and does not need to be re-distributed.
viewer-assets/package.json A file used by npm (a package manager). It defines the dependencies installed by npm, which are required to run Gulp and compile the Viewer Less, icons, and HTML templates. This file is non-essential and does not need to be re-distributed.
viewer-webtier folder Contains files that implement the php layer of communication between the Viewer and the PrizmDoc Application Services.
viewer-webtier/pas.php Handles all requests from the Viewer and forwards them to the PrizmDoc Application Services.
viewer-webtier/pcc.config Defines the connection settings for the PrizmDoc Application Services.
viewer-webtier/PccViewer/Config.php This class parses the pcc.config file and provides methods for easily reading its parameters.
index.php The default web starting page in this sample. The Viewer's code gets loaded by this page.
.htaccess Contains Apache web server settings.
predefinedSearch.json This data file contains information defining search queries that will appear as selectable items in the full Viewer.
redactionReason.json This data file contains information defining redaction reasons that are available in the Viewer.

Folder contents: book-reader-sample

File / Folder Description
viewer-assets folder Contains the essential JavaScript, CSS, fonts, images, language data, and templates (HTML) that make up the book reader Viewer.
viewer-assets/less folder Contains less that can be used to build the Viewer CSS. This folder is non-essential, and does not need to be re-distributed.
viewer-assets/Gruntfile.js Contains Grunt tasks to build the viewer less. This file is non-essential and does not need to be re-distributed.
viewer-assets/package.json A file used by npm (a package manager). It defines the dependencies installed by npm, which are required to run Grunt and compile the less.
viewer-assets/selection.json A file used by the IcoMoon application to generate the icons in the book reader Viewer. If you need to add an icon to the Viewer, you can add the icon to this file and use the IcoMoon application (https://icomoon.io) to generate a new icon font. This file is non-essential and does not need to be re-distributed.
viewer-webtier folder Contains files that implement the php layer of communication between the book reader Viewer and the PrizmDoc Application Services.
viewer-webtier/pas.php Handles all requests from the Viewer and forwards them to the PrizmDoc Application Services.
viewer-webtier/pcc.config Defines the connection settings for the PrizmDoc Application Services.
viewer-webtier/PccViewer/Config.php This class parses the pcc.config file and provides methods for easily reading its parameters.
index.html The default page for the sample. This page loads the Viewer.
sample-config.js Contains references to the assets, web tier, and language files used by the Viewer in this sample.
.htaccess Contains Apache web server settings.

Folder contents: e-signer-sample

File / Folder Description
viewer-assets folder Contains the essential JavaScript, CSS, fonts, images, language data, and templates (HTML) that make up the book reader Viewer.
modules folder Contains uncompiled assets of the Viewer. These files will be compiled to viewer-assets/js/bundle.js and viewer-assets/css/bundle.css by the build process defined in Gulpfile.js.
The files in this folder are non-essential and do not need to be re-distributed.
Gulpfile.js Contains Gulp tasks to build the viewer js and css files. This file is non-essential and does not need to be re-distributed.
viewer-assets/package.json A file used by npm (a package manager). It defines the dependencies installed by npm, which are required to run Gulp and compile the Viewer assets. This file is non-essential and does not need to be re-distributed.
viewer-webtier folder Contains files that implement the php layer of communication between the book reader Viewer and the PrizmDoc Application Services.
viewer-webtier/pas.php Handles all requests from the Viewer and forwards them to the PrizmDoc Application Services.
viewer-webtier/pcc.config Defines the connection settings for the PrizmDoc Application Services.
viewer-webtier/PccViewer/Config.php This class parses the pcc.config file and provides methods for easily reading its parameters.
index.html The default page for the sample. This page loads the Viewer.
.htaccess Contains Apache web server settings.
webpack.config.js Webpack configuration file. This file contains all the settings for the webpack module bundler. We use webpack to compile all the files in the modules folder to the bundle.js and bundle.css that are found in the viewer-assets folder.

Folder contents: template-designer-sample

File / Folder Description
viewer-assets folder Contains the essential JavaScript, CSS, fonts, images, language data, and templates (HTML) that make up the book reader Viewer.
modules folder Contains uncompiled assets of the Viewer. These files will be compiled to viewer-assets/js/bundle.js and viewer-assets/css/bundle.css by the build process defined in Gulpfile.js.
The files in this folder are non-essential and do not need to be re-distributed.
Gulpfile.js Contains Gulp tasks to build the viewer js and css files. This file is non-essential and does not need to be re-distributed.
viewer-assets/package.json A file used by npm (a package manager). It defines the dependencies installed by npm, which are required to run Gulp and compile the Viewer assets. This file is non-essential and does not need to be re-distributed.
viewer-webtier folder Contains files that implement the php layer of communication between the book reader Viewer and the PrizmDoc Application Services.
viewer-webtier/pas.php Handles all requests from the Viewer and forwards them to the PrizmDoc Application Services.
viewer-webtier/pcc.config Defines the connection settings for the PrizmDoc Application Services.
viewer-webtier/PccViewer/Config.php This class parses the pcc.config file and provides methods for easily reading its parameters.
index.html The default page for the sample. This page loads the Viewer.
.htaccess Contains Apache web server settings.
webpack.config.js Webpack configuration file. This file contains all the settings for the webpack module bundler. We use webpack to compile all the files in the modules folder to the bundle.js and bundle.css that are found in the viewer-assets folder.

Configuration with pcc.config

The file pcc.config is used to configure the connection settings between the web tier and PrizmDoc Application Services. The file can be found at: <sample-folder-name>/viewer-webtier/pcc.config. This file is self-documenting, but a little information about the configuration options is given below.

Option Description
<DocumentPath> (Only in splash pages) The sample pulls named documents from this location. The DocumentPath must have read/write permissions in order for the file drag and drop functionality of the splash page to work.
<PrizmApplicationServicesScheme> Specifies the scheme (http or https) to use when connecting with PAS.
<PrizmApplicationServicesHost> Specifies the host to use when connecting with PAS.
<PrizmApplicationServicesPort> Specifies the port to use when connecting with PAS.