I have a whole series of posts, waiting in draft, describing my evolving PHP framework, I call ccPhp. If you have nothing better to do than play with someone else’s dalliances, then here is a quick installation guide. A little backwards, because I’ve yet to publish reasons why you’d want to. But, if, after my eventual publications describe this framework, you decide to install it, this is the quickest place to see how to do that.
The following describes only one way to arrange the setup. I have designed the framework with few cross-dependencies. After my “standard” setup description, I will describe the few file dependencies so that you easily define your own file organization. (If you are on Windows, you can extrapolate the appropriate things to do there).
- Create or choose a working directory, e.g.,
~/work
. We will install the framework directory and project directories.[sourcecode language=”bash” light=”true”]
mkdir ~/work
cd ~/work
[/sourcecode] - Get the framework core sources from download and unpack or from the subversion repository.
[sourcecode language=”bash” light=”true”]
svn checkout http://svn.cachecrew.co/ccphp/ccphp/trunk ccPhp
[/sourcecode]The framework can be installed anywhere; the project specific file simply needs to find and include the
ccApp.php
that is part of the framework. - Copy the sample_project directory from the ccPhp directory for your project:
[sourcecode language=”bash” light=”true”]
cp -r ccPhp/sample_project my_project
[/sourcecode]This directory will contain a “public” directory with a
.htaccess
andindex.php
file which probably won’t need to be changed. - Create
js
,css
,imgs
, etc. directories, as needed, in the public directory. - The public directory needs to be visible to the public; i.e., the web server needs to access this directory. Create a symlink from the web-directory to the public-facing directory. If
~/www/htdocs
is the web server’s document root, the following would the project code to be accessed viahttp://example.com/web
.
[sourcecode language=”bash” light=”true”]
cd ~/www/htdocs
ln -s ~/work/my_project/public web
[/sourcecode]The public directory can be, essentially, placed or referenced anywhere in server’s document-root directory hierarchy, as necessary for users to be able to reach your application. If you want the app to be served at the URL root, then the server’s document-root should be pointed to the public directory.
- Customize the
config.php
for your project. - Code your application as a series of
ccPageInterface
objects. (More about this another time).
Project Organization Flexibility
The framework was designed to support the various styles of file organization that developers prefer. The organization presented above is only one way. The only things that really need to be accomplished:
- The project’s public directory can be located anywhere and called anything, so long as the web server can find it (if, even through a symlink).
- The bulk of the project’s implementation code can be anywhere, so long as the project’s default startup file (i.e.,
index.php
) can find the project code. - The framework can be located anywhere so long as the project’s code can include its
ccApp.php
.
The organization described in this document implements the preceding, by:
- Each project contains a “public” directory that is symlinked from the web servers’ document root directory hierarchy.
- A project contains an initialization
config.php
file that is included by theÂindex.php
in the public directory. - The
config.php
file includes a reference to the framework’sccApp.php
. file. The project directories are in the same directory as the framework.
What’s next?
What can you do with this? Follow my other posts about the ccPhp Framework for more information, arriving soon!