Zend_Uri will build a new URI from scratch
if only a scheme is passed to Zend_Uri::factory().
Example 964. Creating a New URI with Zend_Uri::factory()
<?php
// To create a new URI from scratch, pass only the scheme.
$uri = Zend_Uri::factory('http');
// $uri instanceof Zend_Uri_Http
To create a new URI from scratch, pass only the scheme to
Zend_Uri::factory()[30]. If an unsupported scheme is
passed and no scheme-specific class is specified, a Zend_Uri_Exception
will be thrown.
If the scheme or URI passed is supported,
Zend_Uri::factory() will return a subclass of itself that
specializes in the scheme to be created.
Starting from Zend Framework 1.10.5, you can specify a custom class to be
used when creating the Zend_Uri instance, as a second parameter to the
Zend_Uri::factory() method.
This enables you to subclass Zend_Uri and create your own custom URI classes,
and instantiate new URI objects based on your own custom classes.
The 2nd parameter passed to Zend_Uri::factory() must
be a string with the name of a class extending Zend_Uri.
The class must either be alredy-loaded, or loadable using Zend_Loader::loadClass() -
that is, it must follow the Zend Framework class and file naming conventions, and
must be in your include_path.
Example 965. Creating a URI using a custom class
<?php
// Create a new 'ftp' URI based on a custom class
$ftpUri = Zend_Uri::factory(
'ftp://user@ftp.example.com/path/file',
'MyLibrary_Uri_Ftp'
);
// $ftpUri is an instance of MyLibrary_Uri_Ftp, which is a subclass of Zend_Uri
[30] At the time of writing,
Zend_Uri only provides built-in support for the HTTP
and HTTPS schemes.




