Table of Contents

WebApp Directory structure

Let us use www.openbook.pub as an illustration of the preferred structure of PHP WebApps, built upon the Yii Framework. The WebApp has an old version 1.8.2, a current version 2.0.1, while version 2.1 is currently under development.

/openbook.pub/
/openbook.pub/index.php
/openbook.pub/ad5min_.php
/openbook.pub/...

/mydevsite.com/
/mydevsite.com/index.php
/mydevsite.com/ad5min_.php
/mydevsite.com/...

/openbook.app/
/openbook.app/1.8.2/

/openbook.app/1.8.2/frontend/
/openbook.app/1.8.2/backend/
/openbook.app/1.8.2/common/
/openbook.app/1.8.2/vendor/
/openbook.app/1.8.2/.git/

/openbook.app/2.0.1/frontend/
/openbook.app/2.0.1/backend/
/openbook.app/2.0.1/common/
/openbook.app/2.0.1/vendor/
/openbook.app/2.0.1/.git/

/openbook.app/2.3/

The entry scripts are very simple. The public will access the frontend via /openbook.pub/index.php

require_once (dirname(__DIR__)./openbook.app/2.0.1/frontend/web/production.php');

Maintenance can be done by the administrator on the backend via /openbook.pub/ad5min.php. We have chosen the odd ad5min_.php filename to make the entry harder to guess for hackers.

require_once (dirname(__DIR__)./openbook.app/2.0.1/backend/web/production.php');

Development is done via /mydevsite.com/index.php

require_once (dirname(__DIR__)./openbook.app/2.3/frontend/web/development.php');

Each version of the webapp is complete and independent of other versions. It has its own vendor/ with the Yii framework and other dependencies. Once the version has been published vendor/ will remain unchanged.

Each version also has its own git registry. It can be changed and committed without affect other versions.

The above structure achieves the following

Note that frontend and backend are two separated webapps. When possible, they will share code in common/. But a LoginForm.php may be different, and each will have it in their own models/.

On the other hand, the differences between running an app in development or production mode are limited.

A bare-bones sample application may be copied from /x0data.app/1.0. For example by cp -r x0data.app/1.0 riverbankneighborhood.app/2.0. The Yii manual specifies the following to-do list for this bare-bones webapp:

Error (#32)

Table of Contents

Error (#32)

An internal server error occurred.

The above error occurred while the Web server was processing your request.

Please contact us if you think this is a server error. Thank you.