Skip to content

Commit

Permalink
adding boot and run files
Browse files Browse the repository at this point in the history
  • Loading branch information
wycks committed Feb 9, 2013
1 parent 70a68b0 commit 3bf2001
Show file tree
Hide file tree
Showing 5 changed files with 152 additions and 67 deletions.
69 changes: 40 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,42 @@
WordPhing
=========

WordPress build and other stuff using Phing.
WordPress build script using [Phing](http://www.phing.info/).

- Automated Installing WordPress from the command line (install script).
- Currently builds WordPress in about 30 seconds depending on your Internet connection and how many plugins/themes you include.
- Simple config file and command to run

If you want something that has a lot more features please check out WP-CLI.
https://github.com/wp-cli/wp-cli
- Automated Installing and working with WordPress.
- Simple config file and commands to run


*Phing has no dependencies other than PHP, so it will run anywhere PHP does (unlike Apache Ant/Cappicino/Rails, etc). It should work right out of the box.
*Phing has no dependencies other than PHP, so it will run anywhere PHP does (unlike Apache Ant/Cappicino/Rails, etc). It should work right out of the box on most lamp stacks.

## What does it do?
## Features

Install:
**Installation Automation:**

- Creates a new database (optional)
- Creation of a new database (optional)
- Downloads and installs WordPress (latest stable)
- Download and installs plugins and themes
- Download and installs plugins and/or themes
- Appends needed info to your wp-config
- Runs the WP install script
- Runs the WP install script (by-passes the 5 minute install).
- Runs any custom install parameters (optional via `boot.php`)

Some minor changes are made during install, they are;
**Runtime Automation:**

- Removes Hello Dolly plugin (sry Matt).
- Removes default "Hello World" post, Sample Page, Links.
- Removes default Mr.Wordpress comment.
- Deletes readme.html and wp-sample-config.php
- Allows you to run scripts on a WordPress install,
- For example: delete 1000 posts belonging to a category, see `run.php` for example
- Still in *beta* please do not run on live site

Other:

- Zips or Gzips directory (the whole thing or just your theme/plugin)
**Build Automation:**

- Run PHP Documentor 2
- FTP
- Minify js
- Zips or Gzips

Other:

- Deletes readme.html and wp-sample-config.php


##Basic Instructions
Expand All @@ -45,25 +46,34 @@ Open build.properties and fill it out and also read the comments:)
Command options
- `"phing wp-install"` Creates a database and WordPress
- `"phing wp-install-only"` Creates just WordPress (will not create the database)
- `"phing wp-zip"` Creates a zip
- `"phing wp-gzip"` Creates a gzip
- `"phing wp-run"` Runs custom script
- `"phing wp-doc"` Runs PHP Documentor 2
- `"phing wp-min-js"` Minify JS
- `"phing wp-ftp"` FTP upload
- `"phing wp-zip"` Creates a zip
- `"phing wp-gzip"` Creates a gzip
- `"phing help"` Command line options

Commands are chainable , for example `"phing wp-install wp-gzip"`

The build will not overwrite existing directories or existing databases.
The file/dir permissions (chown) are commented out by default to prevent issues on windows
*The build will not overwrite existing directories or existing databases.*

##Advanced Instructions

WordPhing now contains 2 extra files to run normal PHP and WOrdPress code, have a look at them for examples.
`boot.php` can be run during the install process to customize installation (creation or removing default content).
`run.php` can be run via the `phing wp-run` command on an existing WordPress install

Both files are run from the WordPhing build file root and not the WordPress install root and require build.properties to be properly filled out. You can change the location to to run from the WordPress root in build.xml.


The file/dir permissions (chown) are commented out by default to prevent issues on Windows ( see line 457 in build.xml for reference).

##Requires

PHP 5.2 + & Phing.

Phing is already included in most default PHP installs. If you need to install it separately see "Install" below.

- PHP Documentor 2 requires the latest Phing and the XSL PHP extension. You should also us the latest build found here: http://www.phpdoc.org/
- PHP Documentor 2 requires the latest Phing and the XSL PHP extension. You should use the latest build found here: http://www.phpdoc.org/
- FTP requires Net_FTP http://pear.php.net/package/Net_FTP/redirected

##Notes
Expand All @@ -72,11 +82,14 @@ If there are problems during install you can run WordPhing in debug and verbose

For example: `"phing install -verbose -debug"`

If you want something that has a lot more features please check out WP-CLI.
https://github.com/wp-cli/wp-cli

##Todo

- Add git & svn support
- Add Rsync support
- Add Amazon support
- CSS minify (yui-compress and google closure) requires java
- Moving, staging and backups (phing even has an amazon task)
- Run some tests (phpunit, phpmess)
Expand All @@ -95,7 +108,5 @@ http://www.phing.info/docs/guide/stable/chapters/Setup.html#SystemRequirements

http://pear.phing.info/

Thanks to: https://github.com/etivite/phing-wordpress-installer/

Why Phing? Because it's built with PHP.
https://github.com/phingofficial/phing
22 changes: 22 additions & 0 deletions boot.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
/**
* Used to set up custom parameters during WordPress install process
* Must be in the same DIR as the Phing build script
*
* Only run when using "phing wp-install" or "phing wp-install-only".
*
* @internal This file uses build.properties settings
*
* @package WordPhing
*/


// Add custom install code here


//Example: remove Hello Dolly
delete_plugins(array('hello.php'));



?>
20 changes: 10 additions & 10 deletions build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@

#Full path directory where you want to install WordPress
#Required
build.dir.wp=D:/Sites/bar42
build.dir.wp=D:/Sites/Phingtest

#The database name you want to create or are using.
#Required
build.db.name= bar42
build.db.name= Phingtest

#This is your actual working URL based on your own config/hosts file (http://localhost or ..)
#If you mess this up it will still install WP but you will have to fix it in the database!
#This example is the same as above only for organization it does not have to be the same name.
#Recommended you change this each new install
build.dir.actual=http://dev.local/bar42
build.dir.actual=http://dev.local/Phingtest

#----------------------------------------------

Expand All @@ -29,7 +29,7 @@ build.db.userid= root
build.db.password=
build.db.wp.host= localhost

#Login info - this is normaly set during WordPress install
#Login info - this is normally set during WordPress install

build.wp.title = site title
build.wp.user = admin
Expand All @@ -49,10 +49,10 @@ build.download.wp.url=http://wordpress.org/latest.tar.gz
build.wp.config.db.prefix=wp_

#if you want to enable WP_DEBUG in wp-config.php set to true
build.wp.config.debug=false
build.wp.config.debug=true

#if you want to enable SAVEQUERIES in wp-config.php set to true
build.wp.config.savequeries=false
build.wp.config.savequeries=true

#insert contents of a file into wp-config.php; file must live in same directory as build/props (ie - custom user tables, define statements, etc)
#build.wp.config.append.filename=
Expand Down Expand Up @@ -81,13 +81,13 @@ build.wp.tarball.send = ${build.dir.wp}

# Change this to your plugin / theme or if you want document all of wordpress!
# Set to twentyeleven by default so ya change it
build.wp.docs.dir = ${build.dir.wp}\wp-content\themes\twentyeleven
build.wp.docs.dir = ${build.dir.wp}

# Name of you Documentation - change this it appears in the html ouptut
build.wp.docs.name = TwentyEleven Theme
build.wp.docs.name = all wordpress

# The output directory for Documentor 2 files, default is base wp url /docs
build.wp.doc.output = ${build.dir.wp}\docs
build.wp.doc.output = ${build.dir.wp}\allwp


#----------------------------------------------
Expand Down Expand Up @@ -123,5 +123,5 @@ ftp.dir=/public_html/example

#set to twentyeleven by default
ftp.source=${build.dir.wp}\wp-content\themes\twentyeleven
#app.home=${ftp.host}/myapp


72 changes: 44 additions & 28 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,10 @@
<foo/>
</target>


<adhoc-task name="foo"><![CDATA[
class BarTask extends Task {
public function main() {
function main() {
define( 'ABSPATH', '${build.dir.wp}' . '/');
Expand All @@ -312,42 +311,54 @@
//we need to update the db version for some reason
update_option( 'db_version', $wp_db_version );
//remove Hello Dolly
delete_plugins(array('hello.php'));
//remove default hello world post
wp_delete_post(1,true);
//remove default sample page
wp_delete_post(2,true);
//remove default Mr.Wordpress comment
wp_delete_comment( 1, true ) ;
//edit this script, do not edit this class directly
require('boot.php');
//remove default links
$arr_args = array( 'hide_invisible' => 0 );
$arr_links = get_bookmarks( $arr_args );
// Run through the list and delete 'em
foreach($arr_links as $obj_link) {
wp_delete_link($obj_link->link_id);
}
}
}
]]>
]]>
</adhoc-task>


<target name="delete-readme" description="Deletes readme and wp-config-sample">

<!-- Delete readme -->
<target name="delete-readme" description="Deletes readme and wp-config-sample">
<echo msg="deleting readme.html and wp-config-sample.php" />

<delete file="${build.dir.wp}/readme.html" />
<delete file="${build.dir.wp}/wp-config-sample.php" />

</target>
</target>


<!-- Custom run script
*
* Run any PHP on the current install
* uses run.php
*
************************************************************* -->

<target name="wp-run">
<boo/>
</target>

<adhoc-task name="boo"><![CDATA[
class BooTask extends Task {
function main() {
//this is crazy, blame wordpress
global $domain, $path, $base, $admin_page_hooks, $ajax_results, $all_links, $allowedposttags, $allowedtags, $authordata, $bgcolor, $cache_categories, $cache_lastcommentmodified, $cache_lastpostdate, $cache_lastpostmodified, $cache_userdata, $category_cache, $class, $comment, $comment_cache, $comment_count_cache, $commentdata, $current_user, $day, $debug, $descriptions, $error, $feeds, $id, $is_apache, $is_IIS, $is_macIE, $is_winIE, $l10n, $locale, $link, $m, $map, $max_num_pages, $menu, $mode, $month, $month_abbrev, $monthnum, $more, $multipage, $names, $newday, $numpages, $page, $page_cache, $paged, $pagenow, $pages, $parent_file, $preview, $previousday, $previousweekday, $plugin_page, $post, $post_cache, $post_default_category, $post_default_title, $post_meta_cache, $postc, $postdata, $posts, $posts_per_page, $previousday, $request, $result, $richedit, $single, $submenu, $table_prefix, $targets, $timedifference, $timestart, $timeend, $updated_timestamp, $urls, $user_ID, $user_email, $user_identity, $user_level, $user_login, $user_pass_md5, $user_url, $weekday, $weekday_abbrev, $weekday_initial, $withcomments, $wp, $wp_broken_themes, $wp_db_version, $wp_did_header, $wp_did_template_redirect, $wp_file_description, $wp_filter, $wp_importers, $wp_plugins, $wp_taxonomies, $wp_the_query, $wp_themes, $wp_object_cache, $wp_query, $wp_queries, $wp_rewrite, $wp_roles, $wp_similiesreplace, $wp_smiliessearch, $wp_version, $wpcommentspopupfile, $wpcommentsjavascript, $wpdb;
define('WP_USE_THEMES', false);
require('${build.dir.wp}/wp-blog-header.php');
// edit this script, do not edit this class directly
require('run.php');
}
}
]]>
</adhoc-task>

<!-- Tarballs
************************************************************* -->
Expand Down Expand Up @@ -568,6 +579,11 @@
<echo>FTP Upload Finished!</echo>
</target>

<!-- script run
*************************************************************- -->
<target name="wprun">
<phingcall target="wprun" />
</target>

<!-- Display the available options
************************************************************* -->
Expand Down
36 changes: 36 additions & 0 deletions run.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
/**
* Used to run any script on WordPress.
* Must be in the same DIR as the Phing build script
*
* Use "phing wp-run" to run script
* See http://codex.wordpress.org/Function_Reference for Examples
*
*
* @internal This file uses build.properties settings
*
* @package WordPhing
*/



//Example: to create 35 posts on the fly

for ($k = 0 ; $k < 35; $k++){

// Create post object

$my_post = array(
'post_title' => $k . '- Posts',
'post_content' => 'This is my post.',
'post_status' => 'publish',
'post_author' => 1,
'post_category' => array(1)
);

// Insert the post into the database
wp_insert_post( $my_post );

}

?>

0 comments on commit 3bf2001

Please sign in to comment.