views:

41

answers:

2

I have an application which I want to convert to Zend Application. I have to continue by doing next tasks in zend but previous pages should work as they are working. Existing php project is a simple php project with very simple directory structure and all files are in one folder.

I created a zend project(test) separately and put all existing project files in public folder. I set to local host that points to test/public folder when use test.dev. When I use test.dev in browser then index.php of existing project is called and existing project's initial page is shown. Now I created a controller(person) and action(index). Now when I use test.dev/person/index then existing project content is shown first and then in the end of the page person/index(controller/action) content is shown.

I want if there is controller and action in url then it should show only zend project files content and when there is a file in url then it should show that file simply.

my test/public/index.php file is like this at the moment.

<html>
   <head>
   </head>

   <body>
      This is existing project's index content.
   </body>
</html>

<?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(),
)));

// Determine the protocol to use (http or https).
if (APPLICATION_ENV == 'production') {
    define('HTTP_PROT', 'https://');
} else {
    define('HTTP_PROT', 'http://');
}


/** 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();

?>
+1  A: 

Remove this

<html>
    <head>
    </head>

    <body>
        This is existing project's index content.
    </body>
</html>

From the /public/index.php file.

If you try to access /public/index/ or /public/unknown/action/ then ZF will take over. This is because this file structure should not be present. If the folder you trying to access does not exist in the file structure then ZF will take over and load /public/index.php and start up your ZF application and try and route the request.

If the folder does exist from the old site eg. /public/contact/index.php then the script should load for the contact folder and ZF will not be started.

Is the old site in a CMS or is it just static HTML pages?

Can you tell us exactly what is happening with the current set up you have and why this is not what you want?

jakenoble
Existing project is simple php pages with some javascript work. The problem is that existing project and ZF project both needed an **index.php** file in public folder to start. Therefore I am placing **index.php** code of both projects in single **index.php** in public.
Awan
First I thought that I should place existing project `index.php` content into new `home.php` file but then I have to use the `test.dev/home.php` instead of `test.dev`
Awan
What is in the existing project's `index.php` file? Surely it is not just the simple HTML you pasted in and I said to remove?
jakenoble
Existing `index.php` file is a combination of html+php+javascript. To big to paste here.
Awan
+1  A: 

I think you will find this helpful http://www.chrisabernethy.com/zend-framework-legacy-scripts/

Ozair Kafray