I am new to Zend Framework.
I am running Apache 2.2 and have set the DocumentRoot in the httpd.conf file to the public directory created using Zend_Tool.
Within the public directory I have an .htaccess file;
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
...and an index.php file;
<?php
// Define path to application directory
/*defined('APPLICATION_PATH')
|| */define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));
/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap()->run();
When I type "http://localhost/" into the browser the file index.phtml in the "application/views/scripts/index/" directory is rendered ok.
If I try to access other views using the controller and action names in a url I get a 404 error saying that the requested URL could not be found on the server.
For example I have the controller file TestController.php which is in the same directory as IndexController.php
/TestController.php/
<?php
class TestController extends Zend_Controller_Action
{
public function init()
{
/* Initialize action controller here */
}
public function testAction()
{
// action body
}
}
I have created a test directory containing a file called index.phtml in "application/views/scripts/";
/views/scripts/test/index.phtml/
<br /><br />
<div id="view-content">
<p>View script for controller <b>Test</b> and script/action name <b>index</b></p>
</div>
When I try to render this file by typing "http://localhost/test/" I get a 404 error stating that the requested URL could not be found. All of the Zend Framework documentation I have read and countless other resources all state that this method should render correctly.
I must be missing something, but after an exhaustive search have been unable to find anyone else having this particular problem.
Regards Roan
try creating an indexAction in the test controller... or test.phtml in the directory
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With