Using GitHub as a personal maven repository

Sometime you are in need for a maven repository accessible from the net which is under your control. Reasons might be:

  • a 3rd-party lib is not on Maven central or the desired version is missing
  • you built modules/libraries which will be included in your other projects

With the following steps you will be able to serve any artifact from a public GitHub repository by just added a few lines into your pom.xml. I personally wasted quite an amount of time on this topic so I guess I’ll save it here – for you and me.

Continue reading

Posted in common | Tagged , , , , , , | 1 Comment

Make your bash-prompt git-aware

Today a friend of mine shared a very nice piece of configuration for using git with me.

stevie@box:~/dev/myproject/common [master]$

If you add the following lines into your ~/.bashrc you’ll always know which branch you are on.

Additionally you’ll be informed if the remote branch (if any) has been changed by adding “*” to the branches name. How cool is that?

stevie@box:~/dev/myproject/common [master *]$

Here are the lines to add which will do the magic for you:

1
2
3
4
export GIT_PS1_SHOWDIRTYSTATE=true
export GIT_PS1_SHOWUNTRACKEDFILES=true
export GIT_PS1_SHOWSTASHSTATE=true
export PS1="${PS1::$((${#PS1}-3))}\$(__git_ps1 ' [\[\e[34;1m\]%s\[\e[0m\]]')\$ "
Posted in common | Tagged , , , , | Leave a comment

Bootstrapping Doctrine 1.2 and Zend 1.10/1.11 the easy way

So there seem to be many different ways to get the 1.2 version of Doctrine running with the Zend Framework (currently 1.11) but the easiest way that worked for me, after using the Zend framework command line tool to create a new standard project, made my application bootstrap file look like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
< ?php
 
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
	protected function _initDoctrine()
	{
		$manager = Doctrine_Manager::getInstance();
		$options = $this->getOption("doctrine");
		if(empty($options['models_path']))
			$options['models_path'] =  APPLICATION_PATH . '/models';
 
		foreach($options as $key => $value)
		{
			if($key != 'connection')
				$manager->setAttribute($key, $value);
		}
 
		if(empty($options['connection']))
			throw new Exception("No database connection string provided!");
 
		Doctrine_Manager::connection($options['connection']);
		Doctrine::loadModels($options['models_path']);
		return $manager;
	}
}
?>

The application.ini configuration file then needs some of these information:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
; Database configuration
doctrine.connection = "mysql://user:pass@localhost/database"
doctrine.models_path = APPLICATION_PATH "/models"
doctrine.data_fixtures_path = APPLICATION_PATH . "/data/fixtures"  
doctrine.migrations_path = APPLICATION_PATH . "/data/migrations"  
doctrine.sql_path = APPLICATION_PATH . "/data/sql"
doctrine.yaml_schema_path = APPLICATION_PATH . "/data/schema
; Options for generating models from YAML
doctrine.generate_models_options.phpDocPackage = "Your PHP doc package"
doctrine.generate_models_options.phpDocSubpackage = "Subpackage"  
doctrine.generate_models_options.baseClassName = "Model_"  
doctrine.generate_models_options.phpDocName = "Your name"  
doctrine.generate_models_options.phpDocEmail = "email@address.com"  
; Set this to true to generate base classes. Set to false to make autoloading easier
doctrine.generate_models_options.generateBaseClasses = false

The command line interface is a good way of dealing with model and database generation, this is how the PHP CLI script for Doctrin + Zend looks like (inspired by this post):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/php
< ?php
/**
 * Doctrine CLI script
 */
 
define('APPLICATION_ENV', 'development');
 
define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
 
set_include_path(implode(PATH_SEPARATOR, array(
    realpath(APPLICATION_PATH . '/../library'),
    get_include_path(),
)));
 
require_once 'Zend/Application.php';
 
// Create application, bootstrap, and run
$application = new Zend_Application(
    APPLICATION_ENV,
    APPLICATION_PATH . '/configs/application.ini'
);
 
$application->getBootstrap()->bootstrap('doctrine');
 
$config = $application->getOption('doctrine');
 
$cli = new Doctrine_Cli($config);
$cli->run($_SERVER['argv']);
?>

With this you can get started to use Doctrine + Zend Framework.

Posted in common | Tagged , , | 1 Comment