Search code examples
phpzend-frameworkdeploymentphpfog

How do I deploy a Zend Framework application to PHP Fog?


I am new to PHP. I have a PHP application which I need to deploy to PHP Fog. I have already configured the database and the credentials to use the remote repository using git. I can push the content to PHP fog.

The problem is that I don't understand what I have to push, why I have so many folders.

The zip file contains the following folders: application library nbproject public 1.clpprj (What is this?)

application contains the folders: configs, forms, layouts, models, modules, pdf and the file Bootstrap.php which starts with the following line: class Bootstrap extends Zend_Application_Bootstrap_Bootstrap.

public contains a lot of folders and files. I think that this is the root of the project. it contains folders like img, js, fonts, css, the file index.php.

I received the following instructions:

1) define the folder for hosting, if you have access to the root of the site that copy all the are stored in the "public" folder in the archive to the root of the site

2) if you have access to one directory above the root of the site, then copy there all the other folders (except for "public") .

Any help deploying this application?


Solution

  • The minimally required folders in the Zend Framework are the bin and library folders. The other folders are accessories and samples. The library folder along with your application need to be pushed to PHP Fog.

    The application folder is where you will create controllers, models, and views for your app. The library folder is where you would place reusable code needed by one or more controller. nbproject and .clpprj files are associated with the NetBeans IDE.

    Here is a quick start tutorial that will get you up and running with a starter app on PHP Fog. Once you get this working you should be able to use the code from the application code you downloaded.

    1. Create a new PHP Custom app from the PHP Fog console

    2. Clone it to your local machine (I'm assuming MacOS or Linux). Change directory to the cloned folder.

    3. Place all the files and folders from the Zend Framework Zend Framework 1.11 full download into the cloned folder.

    4. Create a .gitignore file in the cloned folder with the following contents:

      demos
      externals
      extras
      incubator
      resources
      src
      tests
      
    5. From the cloned folder run the following command to create a new application:

      bin/zf.sh create project myproject

      This creates a new folder named myproject. At this point your cloned project folder should look like this:

      INSTALL.txt README.txt  demos       extras      index.php   myproject   src
      LICENSE.txt bin         externals   incubator   library     resources   tests
      
    6. Edit the myproject/public/index.php file and add the root library along with the project library to the includes paths.

      // Ensure library/ is on include_path
      set_include_path(implode(PATH_SEPARATOR, array(
          realpath(APPLICATION_PATH . '/../library'), // <----Keep this line
          realpath(APPLICATION_PATH . '/../../library'), // <----- Add This line
          get_include_path(),
      )));
      
    7. In the PHP Fog console under setting set the following base path:

      myproject/public

    8. Add the changes to the repo and push to PHP Fog

      git add -A
      git commit -m "First Commit"
      git push
      

    Wait a few seconds after the push and your app should deploy with the default "Welcome to the Zend Framework!" 404 page.

    I would then take a look at this article Zend Framework from Scratch and skip to step 4.