Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Created install script

Updated loadTestDb.php to use APPLICATION_ENV constant
Added data/db/ directory
Updated instructions in README.txt
  • Loading branch information...
commit d911a0f67bdf94e1c3ead3c2f92a89da4e508fc6 1 parent cee9905
@weierophinney authored
View
51 README.txt
@@ -3,6 +3,21 @@ features of the Dojo/Zend Framework integration.
INSTALLATION
=======================================================================
+This application requires that you either have Zend Framework on your
+include_path, or that you will be symlinking your Zend Framework library
+into the library directory. If you do not yet have Zend Framework, you
+can get it from one of the following sources:
+
+ * Official Release:
+ http://framework.zend.com/dowload/latest
+
+ * Subversion; use either the current trunk or the 1.7 release branch:
+ svn co http://framework.zend.com/svn/framework/standard/trunk/library/Zend
+
+ svn co http://framework.zend.com/svn/framework/standard/branches/release-1.7/library/Zend
+
+Install Zend Framework locally, and the follow these steps:
+
1. Untar the archive using:
tar xzf <packagefile>
@@ -14,36 +29,18 @@ INSTALLATION
(Assuming /var/www contains directories for your vhosts.)
-3. Symlink or install the library/Zend/ directory of your Zend Framework
- installation (1.6.0RC1 or later, or current trunk) to library/Zend/
- -- this is done to keep the tarball size down.
-
- Alternately, you can grab current trunk or the 1.7 release branch
- from SVN using:
-
- svn co http://framework.zend.com/svn/framework/standard/trunk/library/Zend
-
- svn co http://framework.zend.com/svn/framework/standard/branches/release-1.7/library/Zend
-
-4. If you are on Windows, rename the public/js-src directory to
- public/js; on *nix, verify that public/js is a symlink to
- public/js-src.
-
-5. Make the directory application/data and all files within it world
- writeable; this can be accomplished on *nix systems using:
-
- chmod -R a+rwX <packagedir>/application/data
+3. Run the install script
+ The application now comes with an install script, that creates the
+ necessary symlinks, initializes the development database, and sets
+ appropriate permissions. Simply run it using php:
-6. Make the directory public/api/spindle/paste/content world writeable; this can
- be accomplished on *nix systems using:
+ php install.php path/to/ZendFramework/library/Zend
- chmod a+rwX <packagedir>/public/api/spindle/paste/content
+ You can get full usage by passing the -h, --help, or -? options:
- This will only affect you when you set the application environment to
- "production", at which time artifacts will be written to the
- directory.
+ php install.php -h
-7. Create a vhost that points its DocumentRoot to the public
+3. Create a vhost that points its DocumentRoot to the public
subdirectory. As an example:
<VirtualHost *>
@@ -65,7 +62,7 @@ INSTALLATION
127.0.1.1 paste.local
-8. Finally, simply fire your browser to:
+4. Finally, simply fire your browser to:
http://paste.local/
View
7 TODO
@@ -3,10 +3,3 @@
- JS that updates main content pane either
- from HREF
- creating basic structure
-- Create an install script
- - should set appropriate permissions
- - data directory (world writeable)
- - api/spindle/paste/content directory (world writeable)
- - should optionally allow specifying directory containing ZF to symlink in
- - should symlink js-src js
- - should create dev database (if ZF is detected)
View
0  data/db/.placeholder
No changes.
View
91 install.php
@@ -0,0 +1,91 @@
+<?php
+define('APPLICATION_ENV', 'development');
+$cwd = realpath(dirname(__FILE__));
+$zfdir = null;
+if (1 < $argc) {
+ $arg0 = $argv[1];
+ if (in_array($arg0, array('-h', '--help', '-?'))) {
+ help();
+ exit;
+ }
+
+ $zfdir = $argv[1];
+}
+
+echo "Creating required symlinks...\n";
+createLink($cwd . '/public/js-src', $cwd . '/public/js');
+if ($zfdir) {
+ createLink($zfdir, $cwd . '/library/Zend');
+}
+echo "[DONE] Creating required symlinks\n\n";
+
+echo "Creating initial database...\n";
+include $cwd . '/scripts/loadTestDb.php';
+echo "[DONE] Creating initial database\n\n";
+
+echo "Setting permissions...\n";
+dirSetPerms($cwd . '/data', 0777);
+dirSetPerms($cwd . '/public/api/spindle/paste/content', 0777);
+echo "[DONE] Setting permissions\n\n";
+
+// Done
+echo <<<EOM
+Thank you for trying this application. To use it, please make sure you have
+setup an apache vhost (or similar functionality on other web servers) according
+to the instructions in the README.txt file.
+EOM;
+
+function help()
+{
+ echo<<<EOM
+install.php - setup Spindle application
+Sets up the Spindle application by creating appropriate symlinks, setting
+appropriate permissions for data directories, and preparing the initial
+database.
+
+Arguments:
+ -h, --help, -?: Print this message
+ path : Path to Zend framework 'library/Zend' directory; this will
+ be symlinked into library/Zend
+
+Example:
+ % php install.php /opt/ZendFramework/library/Zend
+
+EOM;
+}
+
+function dirSetPerms($target, $perms)
+{
+ echo " Setting permissions for $target to $perms...\n";
+ chmod($target, $perms);
+ $iterator = new RecursiveDirectoryIterator($target);
+ foreach (new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::SELF_FIRST) as $file) {
+ $name = $file->getPathName();
+ echo " Updating $name\n";
+ chmod($file->getPathName(), $perms);
+ }
+ echo " [DONE] Setting permissions for $target to $perms\n";
+}
+
+function createLink($target, $name)
+{
+ echo " Linking $name to $target... ";
+
+ if (file_exists($name)) {
+ echo "link already exists; [DONE]\n";
+ return;
+ }
+
+ if (strtolower(substr(PHP_OS, 0, 3)) == 'win') {
+ if (strstr($target, 'js-src')) {
+ rename($target, $name);
+ } else {
+ echo "Cannot create symlinks on Windows; you will manually need to do this\n";
+ return;
+ }
+ } else {
+ symlink($target, $name);
+ }
+
+ echo "[DONE]\n";
+}
View
9 scripts/loadTestDb.php
@@ -3,9 +3,10 @@
* Script for creating and loading test database
*/
-if (!defined('APPLICATION_PATH')) {
- define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application/'));
-}
+defined('APPLICATION_PATH')
+ || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application/'));
+defined('APPLICATION_ENV')
+ || define('APPLICATION_ENV', 'testing');
if (!class_exists('Zend_Registry', false) || !Zend_Registry::isRegistered('config')) {
@@ -19,7 +20,7 @@
Zend_Loader::registerAutoload();
}
- $config = new Zend_Config_Ini(APPLICATION_PATH . '/config/site.ini', 'testing');
+ $config = new Zend_Config_Ini(APPLICATION_PATH . '/config/site.ini', APPLICATION_ENV);
Zend_Registry::set('config', $config);
unset($base, $path, $config);
}
Please sign in to comment.
Something went wrong with that request. Please try again.