Kategorien
Agavi Apache Frameworks

Agavi auf XAMPP und Windows

Nachdem ich das offizielle Agavi DOC durchforstet habe und keine Lösung für meine Testumgebung fand, stieß ich auf diesen Link hier:

simonholywell.com/article/installing-agavi-on-xampp-windows

Herr Holywell selbst hat eine prima Einführung in die Installation von Agavi auf XAMPP und Windows geliefert.

Hier der Post im Original:

Having recently heard of the Agavi project from a web framework showdown at a PHP conference in the UK I have decided to trial it. My setup is a WinXP computer with a default install of the latest XAMPP which has thrown up some issues with installing and building Agavi. Please see my hints below to overcome these issues.

1. Open a command prompt (type cmd in the run console)
2. Navigate to your XAMMP PHP directory. Mine is C:\xampp-test\php
3. Execute pear.bat channel-discover pear.agavi.org
4. Execute pear.bat install agavi/agavi

Agavi is now installed! Now we just need a new default project to work from.

Agavi needs to be told where the phing batch file is stored.

1. Edit the agavi.bat file in the XAMPP php directory. Mine is C:\xampp-test\php\agavi.bat
2. Change set PHING_COMMAND=phing to contain the full absolute path to phing.bat which is in the XAMPP php folder. Mine looks like this: set PHING_COMMAND=C:\xampp-test\php\phing.bat

Begin setting up your project directory.

1. Create a new directory in your XAMPP directory. Mine is C:xampp-testhtdocssimonholywell.com
2. Create an empty text file called build.properties in the directory (this banishes a build error where phing fails if it cannot find the file)
3. Open a command prompt and navigate to the new directory
4. Execute agavi.bat project The agavi.bat file is stored in the XAMPP php folder. My command looked like this: C:\xampp-test\php\agavi.bat project
5. Follow the prompts the installer gives you (hitting enter will supply the installer with the [default] value)

Agavi should now be setup for your project. View it in your browser to verify.

Kategorien
SVN Versionierung

die SVN Quickreferenz als PDF

…für alle die mal eben schnell SVN Kommandos nachsehen wollen.

Subversion_Quickreferenz.pdf

© by Tobias Zeising (tobias.zeising@aditu.de | http://www.aditu.de)

Kategorien
Kohana PHP SOAP Zend

SOAP Service mit Kohana und Zend AutoDiscover

Eine einfache all-in-one Lösung für Standard SOAP Services kann man mit dem Kohana Framework und der Zend Bibliothek realisieren.

Dazu bedarf es lediglich eines Kohana Frontcontrollers über den wir den Service und die WSDL ansprechen können.

Zur automatischen Generierung der WSDL, bedienen wir uns hier der Zend AutoDiscover Klasse. Dieser Klasse übergibt man lediglich die ServiceModel-Klasse mit enthaltenen Annotationen, die die Servicefunktionen enthält.

Aus den Annotationen generiert Zend AutoDiscover eine passende WSDL.


/**
 * include libs and models
 *
 */
include('Zend/Soap/AutoDiscover.php');
include(APPPATH . 'models/service.php');

/**
 * this class represents a controller
 * application/controllers/soap.php
 *
 * @package     SOAPService
 * @subpackage  ...
 * @author      saegefisch (xxx@xxx.xx)
 * @copyright   (c) 2009 xxx
 */
class Soap_Controller extends Controller
{
    /**
     * default constructor
     *
     * @param void
     * @return void
     */
    public function __construct()
    {
        // load parent constructor
        parent::__construct();
    }

    /**
     * service to call
     *
     * @param void
     * @return void
     */
    public function service()
    {
        // disable wsdl cache
        ini_set('soap.wsdl_cache_enabled', '0');

        // set auth settings if needed
        $settings   = array(
                          'login'              => 'user',
                          'password'        => 'password',
                          'authentication' => SOAP_AUTHENTICATION_BASIC,
                          'soap_version'   => SOAP_1_2,
                          'encoding'         => 'UTF-8',
                          'cache_wsdl'     => WSDL_CACHE_NONE
                          );

        // include user:password if needed
        $wsdl = 'http://user:password@' . $_SERVER['HTTP_HOST'] . '/soap/wsdl';
        $server = new SoapServer($wsdl, $settings);
        $server->setClass('Service_Model');
        $server->handle();
    }

    /**
     * wsdl to call
     *
     * @param void
     * @return void
     */
    public function wsdl()
    {
        // disable wsdl cache
        ini_set('soap.wsdl_cache_enabled', '0');

        $wsdl = new Zend_Soap_AutoDiscover();
        $wsdl->setUri('http://' . $_SERVER['HTTP_HOST'] . '/soap/service');
        $wsdl->setClass('Service_Model');
        $wsdl->handle();
    }
}

Hier stellen wir das Standard Model für unseren SOAP Service zusammen.


/**
 * this class represents a model
 * application/models/service.php
 *
 * @package     SOAPService
 * @subpackage  ...
 * @author      saegefisch (xxx@xxx.xx)
 * @copyright   (c) 2009
 */
class Service_Model extends Model
{
    /**
     * default constructor
     *
     * @param   void
     * @return  void
     */
    public function __construct()
    {
        // load database library into $this->db (can be omitted if not required)
        parent::__construct();
    }

    /**
     * dummy function
     *
     * @param   int $int
     * @param   string $string
     * @param   array $arr
     * @param   object $obj
     * @param   bool $bool
     * @return  array
     */
    public function get_dummy_array($int, $string, $arr, $obj, $bool)
    {
        return array();
    }

    /**
     * dummy function
     *
     * @param   int $int
     * @param   string $string
     * @param   array $arr
     * @param   object $obj
     * @param   bool $bool
     * @return  bool
     */
    public function get_dummy_boolean($int, $string, $arr, $obj, $bool)
    {
        return true;
    }

    /**
     * dummy function
     *
     * @param   int $int
     * @param   string $string
     * @param   array $arr
     * @param   object $obj
     * @param   bool $bool
     * @return  string
     */
    public function get_dummy_string($int, $string, $arr, $obj, $bool)
    {
        return 'foo=bar';
    }
}

Kategorien
MySQL PHP Propel ORM

der Criteria Builder für Propel ORM Criterias

propel_criteria_builder

Die Propel ORM für PHP bedient sich einer eigenen Syntax (Criterias) um Queries zusammenzustellen.

Hier gibt es einen Criteria Builder, den man mit Standard SQL füttern kann.

Der Criteria Builder konvertiert sodann das eingegebene SQL Statement in ein Propel Criteria.

So wird aus diesem kleinen SQL Statement:


SELECT user.*
FROM user
WHERE user.state = 100 
AND (user.name = 'user' OR user.email = 'user@domain.tld')

diese Propel Criteria:


$c = new Criteria();
$crit0 = $c->getNewCriterion(UserPeer::STATE, 100);
$crit1 = $c->getNewCriterion(UserPeer::NAME, 'user');
$crit2 = $c->getNewCriterion(UserPeer::EMAIL, 'user@domain.tld');

// Perform OR at level 1 ($crit1 $crit2 )
$crit1->addOr($crit2);

// Perform AND at level 0 ($crit0 $crit1 )
$crit0->addAnd($crit1);

// Remember to change the peer class here for the correct one in your model
$c->add($crit0);
$result = TablePeer::doSelect($c);

// This loop will of course need to be edited to work
foreach ($result as $obj)
{
	//$val = $obj->getValue();
}

Einen Versuch ist es Wert.

Hier gehts zum Propel ORM Criteria Builder