Solar和工作区文件类库的良好组织是有益于核心应用的,通常来说,你需要在web服务器或其他目标主机中布署Solar类库和工作区类库。这就意味着,对于不同的文件支持和SVN外部系统,类库组织要一致;我们把它称为你的项目的Solar“系统”。
下面是Solar“系统”的主要文件和目录:
SYSTEM/
index.php # quick-start (insecure) bootstrap
config.php # main config file
config/ # other config files
docroot/ # web server document root
.htaccess # mod-rewrite rules
index.php # real bootstrap file
public/ # public assets
Solar/ # Solar assets
include/ # used as the php include_path
script/ # command-line scripts
solar # the solar command-line tool
source/ # source packages, libraries, etc
sqlite/ # sqlite files
tmp/ # temp files
cache/ # private cache
log/ # log files
mail/ # test emails
session/ # session files
Solar“系统”下面有“四大”目录:source/、include/、config/和docroot/。其他文件和目录比较容易理解,不言自明。
所有的源代码文件都放置在source/目录下,包括使用make-vendor生成的文件。source/目录不会用于include路径。它是所有代码托管中心。(我们马上就会接触到include路径)
source/目录不关心你在里面放置了什么代码。你可以下载并解压PEAR风格包、放置第三方类库、SVN或git。你甚至可以在里面放置同一类库的不同版本,只需要把它们放置在不同的子目录中即可。
source/目录组织结构如下:
source/
acme/ # libraries from the `make-vendor Acme` CLI call
Acme.php
Acme/
config/
script/
docs/
tests/
example/ # svn:externals http://svn.example.com/trunk
...
solar/ # core Solar libraries
Solar.php
Solar/
config/
script/
docs/
tests/
third-party/ # copied or downloaded from a third party
...
include/目录是你整个Solar系统代码的include路径。一般情况下,include/目录里只含有到source/目录的符号链接(symlinks)。这意味着include/目录可以拥有source/目录下的所有文件,而且不会污染include路径。这也意味着你可以随意互换源目录,通过改变符号链接(symlinks)的指向。
include/目录的组织结构如下:
include/
Acme.php # ln -s ../source/acme/Acme.php
Acme/ # ln -s ../source/acme/Acme
Example/ # ln -s ../source/Example
Solar.php # ln -s ../source/solar/Solar.php
Solar/ # ln -s ../source/solar/Solar
thirdparty.php # ln -s ../source/third-party/some_file.php
如果你使用make-vendor命令,它会自动为你产生这些符号链接(支持windows vista和unix风格的符号链接)。如果你引入了你自己的源代码:如果它们是Solar风格的工作区,那么你可以通过link-vendor命令为你创建符号链接;如果不是,那么你只能自己创建符号链接。
接下来是config/目录。它放置了系统所有的配置文件。
config.php
config/
access.txt # an example ACL file
htpasswd.conf # an example password file
thirdparty.ini # a .ini file for a third-party library
“四大”目录的最后一个目录是docroot/目录。这是系统的Web服务器文件根目录。你的虚拟主机应该配置指向这个目录,而不是SYSTEM目录。
子目录public/保存公共的附件,例如,Javascript文件、
样式表、图片等。在Solar风格的工作区中,最后一个目录实际上是每个类指向public/目录的符号链接。这允许你随类包分布这些公共附件,而不必有每次有更改时复制这些附件。
public/目录的组织结构如下:
docroot/
index.php # bootstrap file
public/ # public assets
Solar/ #
View/ #
Helper/ #
Pager/ # ln -s SYSTEM/source/Solar/View/Helper/Pager/Public
如果你创建类的同时用到Public/子目录存放公共附件,那么你可以使用link-public命令自动产生这些符号链接。(支持windows vista和unix风格的符号链接)

