Upgrading from v3.3

Since version 4.0, PRADO classes make use of PHP namespaces in its internal classes, enabling the autoloading of PHP class files using a PSR-4 autoloader.
Proper changes have been made to ensure that code running on PRADO 3.x will work on 4.x requiring only minor changes.

Composer support has been added. Composer is used both to manage library dependencies and classes autoloading.
Previous PRADO versions used to bundle external php and javascript libraries, making it hard for users to update them. All these libraries have been removed and will be installed by Composer.
PRADO's autoloader used to error out every time a PHP class could not be found, making it hard to include external libraries that used their own autoloaders. The PSR-4 standard was created to define a common autoloading pattern, and letting Composer handle autoloading solves this problem.

External PHP libraries will be obtained from Packagist, the default package repo for Composer. Javascript libraries will be obtained from Asset Packagist, a project that collects libraries from two popular Javascript package managers Bower and NPM and presents them in a Composer-compatible fashion.

Porting an application

In order to port a PRADO 3.3 application to 4.0, the first step is to install composer.

$ curl -s http://getcomposer.org/installer | php
$ php composer.phar install

Then create a composer.json file for your project. An example composer.json file is published on the PRADO demo app repository. If your project already uses Composer, just add the following library requirement:

{
    "require": {
        "pradosoft/prado": "~4.0"
    }
}

Now run the actual installation:

$ composer install
Composer will download and install PRADO and all the required dependencies inside the protected/vendor subfolder. The default path can be changed modifying the vendor-dir option.
"config": {
		"vendor-dir": "protected/vendor"
	}

The next step is to make your project use the composer autoloader. Open the index.php entry script of your project, find the lines where PRADO gets loaded and the application started:

// Old, PRADO 3.x

// load PRADO framework
require_once("path/to/prado.php");

// instanciate TApplication
$application=new TApplication;

// Run the application
$application->run();

and replace these lines with their equivalent for PRADO 4.x:

// New, PRADO 4.x

// load composer autoloader
require 'protected/vendor/autoload.php';

// instanciate the namespaced TApplication
$application = new \Prado\TApplication;

// Run the application
$application->run();

Now, try to access your application and it will hopefully run just mostly fine.

Advanced porting: hiding composer

By default in PRADO 3.x the application directory lives inside the web root, so all the files inside it are accessible from a web browser. Access to the protected directory is forbidden, and you may want to forbid access to composer and its files, too.
The example composer.json shown above places the vendor folder inside the protected directory, so direct access to the libraries downloaded by composer is already forbidden.
Instead, both composer.json and composer.lock (created by composer when first run) are placed on the main directory, so you may want to forbid access to them, too. This can be accomplished on the Apache web server using a .htaccess file, or an equivalent method for other webserver software you may be using. Following is an example .htaccess snippet:

# Prevent direct access to certain files
<FilesMatch ^(composer\.(json|lock)$)$>
    Deny from all
</FilesMatch> 

Advanced porting: bundling libraries

If your project uses third party libraries, you can let Composer install and handle them.
In the following example a class is using PHPExcel including it directly:

require_once("phpexcel/Classes/PHPExcel.php");

public function createSpreadsheet()
{
	$obj = new PHPExcel;
	$obj->...
}

First, in your composer.json add the dependency on the PHPExcel library:

"require": {
    	"pradosoft/prado": "~4.0"
        "phpoffice/phpexcel": "~1"
    }

Then run composer update to get Composer download the library and its dependecies, install them and recreate the autoloader with the new library informations.

Last, modify the class to make use of the namespace of the library:

use PHPExcel;

public function createSpreadsheet()
{
	$obj = new PHPExcel;
	$obj->...
}