Catalyst::View::PHP - Template View Class
# use the helper myapp_create.pl view PHP PHP # lib/MyApp/View/PHP.pm package MyApp::View::PHP; use base 'Catalyst::View::PHP'; # To set the override the PHP include path set the path in the config. __PACKAGE__->config->{INCLUDE_PATH} = '/usr/local/generic/templates:/usr/local/myapp/templates'; 1; # Meanwhile, maybe in a private C<end> action $c->forward('MyApp::View::PHP');
This is the Catalyst view class for the PHP::Interpreter. Your application subclass should inherit from this class. This plugin renders the template specified in $c->stash->{template}, or failing that, $c->request->match. The template variables are set up from the contents of $c->stash, augmented with template variable base set to Catalyst's $c->req->base, template variable c to Catalyst's $c, and template variable name to Catalyst's $c->config->{name}. The output is stored in $c->response->output.
$c->stash->{template}
$c->request->match
$c->stash
base
$c->req->base
c
$c
name
$c->config->{name}
$c->response->output
If you want to override PHP config settings, you can do it in your application's view class by setting __PACKAGE__->config->{OPTION}, as shown in the Synopsis. See the available options document on the PHP::Interpreter documentation.
__PACKAGE__->config->{OPTION}
In PHP the variables exported are the requests parameters for $_GET and $_POST depending on the method used to send the request. Also all of the stash is exported just like in TemplateToolkit, and you can access the current context by calling $c.
$_GET
$_POST
For example to read the CGI parameter 'test' you can use:
$_GET['test']
or
print $c->request->parameters['test']
Or to get the method of the request try:
print $c->request->method
There are probably a few as this module is very new along with PHP::Interpreter being very new. Feel free to discuss this module on the Catalyst mailing list catalyst@lists.rawmode.org.
This module has been tested with PHP 5.1.0RC1 (cli).
The constructor for the PHP view. Sets up the template provider, and reads the application config.
Renders the template specified in $c->stash->{template} or $c->request->match. Template variables are set up from the contents of $c->stash, augmented with base set to $c->req->base, c to $c and name to $c->config->{name}. Output is stored in $c->response->output.
Being that there is no clear way to reset the interpreter between requests, each request is processed in a new interpreter instance. As PHP::Interpreter matures this may change.
This allows your view subclass to pass additional settings to the PHP config hash.
Catalyst, PHP::Interpreter, http://www.php.net
Rusty Conover, rconover@infogears.com
rconover@infogears.com
Based off of Catalyst::View::TT by:
Sebastian Riedel, sri@cpan.org Marcus Ramberg, mramberg@cpan.org Jesse Sheidlower, jester@panix.com
sri@cpan.org
mramberg@cpan.org
jester@panix.com
Copyright (c) 2005 InfoGears, Inc. All Rights Reserved. http://www.infogears.com/
This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself.
To install Catalyst::View::PHP, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Catalyst::View::PHP
CPAN shell
perl -MCPAN -e shell install Catalyst::View::PHP
For more information on module installation, please visit the detailed CPAN module installation guide.