Skip to content

Commit

Permalink
Renaming project
Browse files Browse the repository at this point in the history
  • Loading branch information
Ocramius committed Jul 11, 2013
1 parent 96714fc commit 78d5fd3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 185 deletions.
3 changes: 1 addition & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
To install the project and run the tests, you need to clone it first:

```sh
git clone git://github.com/Ocramius/ProxyManager.git
git clone git://github.com/Ocramius/GeneratedHydrator.git
```

You will then need to run a composer installation:
Expand All @@ -32,4 +32,3 @@ The PHPUnit version to be used is the one installed as a dev- dependency via com

Accepted coverage for new contributions is 80%. Any contribution not satisfying this requirement
won't be merged.

170 changes: 2 additions & 168 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,169 +1,3 @@
# Proxy Manager

This library aims at providing abstraction for generating various kinds of [proxy classes](http://marco-pivetta.com/proxy-pattern-in-php/).

Currently, this project supports generation of **Virtual Proxies** and **Smart References**.
Additionally, it can generate a small high-performance **Hydrator** class to optimize transition
of data from and into your objects.

[![Build Status](https://travis-ci.org/Ocramius/ProxyManager.png?branch=master)](https://travis-ci.org/Ocramius/ProxyManager)
[![Coverage Status](https://coveralls.io/repos/Ocramius/ProxyManager/badge.png?branch=master)](https://coveralls.io/r/Ocramius/ProxyManager)
[![Total Downloads](https://poser.pugx.org/ocramius/proxy-manager/downloads.png)](https://packagist.org/packages/ocramius/proxy-manager)
[![Latest Stable Version](https://poser.pugx.org/ocramius/proxy-manager/v/stable.png)](https://packagist.org/packages/ocramius/proxy-manager)
[![Latest Unstable Version](https://poser.pugx.org/ocramius/proxy-manager/v/unstable.png)](https://packagist.org/packages/ocramius/proxy-manager)
[![Dependency Status](https://www.versioneye.com/package/php--ocramius--proxy-manager/badge.png)](https://www.versioneye.com/package/php--ocramius--proxy-manager)

## Installation

The suggested installation method is via [composer](https://getcomposer.org/):

```sh
php composer.phar require ocramius/proxy-manager:0.4.*
```

## Lazy Loading Value Holders (Virtual Proxy)

ProxyManager can generate [lazy loading value holders](http://www.martinfowler.com/eaaCatalog/lazyLoad.html),
which are virtual proxies capable of saving performance and memory for objects that require a lot of dependencies or
CPU cycles to be loaded: particularly useful when you may not always need the object, but are constructing it anyways.

```php
$config = new \ProxyManager\Configuration(); // customize this if needed for production
$factory = new \ProxyManager\Factory\LazyLoadingValueHolderFactory($config);

$proxy = $factory->createProxy(
'MyApp\HeavyComplexObject',
function (& $wrappedObject, $proxy, $method, $parameters, & $initializer) {
$wrappedObject = new HeavyComplexObject(); // instantiation logic here
$initializer = null; // turning off further lazy initialization

return true;
}
);

$proxy->doFoo();
```

See the [complete documentation about lazy loading value holders](https://github.com/Ocramius/ProxyManager/tree/master/docs/lazy-loading-value-holder.md)
in the `docs/` directory.

## Access Interceptors

An access interceptor is a smart reference that allows you to execute logic before and after a particular method
is executed or a particular property is accessed, and it allows to manipulate parameters and return values depending
on your needs.

```php
$config = new \ProxyManager\Configuration(); // customize this if needed for production
$factory = new \ProxyManager\Factory\AccessInterceptorValueHolderFactory($config);

$proxy = $factory->createProxy(
new \My\Db\Connection(),
array('query' => function () { echo "Query being executed!\n"; }),
array('query' => function () { echo "Query completed!\n"; })
);

$proxy->query(); // produces "Query being executed!\nQuery completed!\n"
```

See the [complete documentation about access interceptor value holders](https://github.com/Ocramius/ProxyManager/tree/master/docs/access-interceptor-value-holder.md)
in the `docs/` directory.

## Fallback Value Holders

A fallback value holder is a particular value holder that implements the [null object pattern](http://en.wikipedia.org/wiki/Null_Object_pattern).

This kind of value holder allows you to have fallback logic in case loading of the wrapped value failed.

This feature is [planned](https://github.com/Ocramius/ProxyManager/issues/5).

## Ghost Objects


Similar to value holder, a ghost object is usually created to handle lazy loading.

The difference between a value holder and a ghost object is that the ghost object does not contain a real instance of
the required object, but handles lazy loading by initializing its own inherited properties.

ProxyManager can generate [lazy loading ghost objects](http://www.martinfowler.com/eaaCatalog/lazyLoad.html),
which are proxies used to save performance and memory for large datasets and graphs representing relational data.
Ghost objects are particularly useful when building data-mappers.

Additionally, the overhead introduced by ghost objects is very low when compared to the memory and performance overhead
caused by virtual proxies.

```php
$config = new \ProxyManager\Configuration(); // customize this if needed for production
$factory = new \ProxyManager\Factory\LazyLoadingGhostFactory($config);

$proxy = $factory->createProxy(
'MyApp\HeavyComplexObject',
function ($proxy, $method, $parameters, & $initializer) {
$initializer = null; // turning off further lazy initialization

// modify the proxy instance
$proxy->setFoo('foo');
$proxy->setBar('bar');

return true;
}
);

$proxy->doFoo();
```

See the [complete documentation about lazy loading ghost objects](https://github.com/Ocramius/ProxyManager/tree/master/docs/lazy-loading-ghost-object.md)
in the `docs/` directory.

This feature is [planned](https://github.com/Ocramius/ProxyManager/issues/6).

## Lazy References

A lazy reference proxy is actually a proxy backed by some kind of reference holder (usually a registry) that can fetch
existing instances of a particular object.

A lazy reference is usually necessary when multiple instances of the same object can be avoided, or when the instances
are not hard links (like with [Weakref](http://php.net/manual/en/book.weakref.php)), and could be garbage-collected to
save memory in long time running processes.

This feature [yet to be planned](https://github.com/Ocramius/ProxyManager/issues/8).

## Remote Object

A remote object proxy is an object that is located on a different system, but is used as if it was available locally.
There's various possible remote proxy implementations, which could be based on xmlrpc/jsonrpc/soap/dnode/etc.

This feature [yet to be planned](https://github.com/Ocramius/ProxyManager/issues/7).

## Hydrator

A [hydrator](http://framework.zend.com/manual/2.1/en/modules/zend.stdlib.hydrator.html) is an object that can read
other object's data or fill them with values. ProxyManager can generate highly optimized hydrator objects to speed up
batch processing of instantiation of a large number of objects.

```php
$config = new \ProxyManager\Configuration();
$factory = new \ProxyManager\Factory\HydratorFactory($config);

$hydrator = $factory->createProxy('My\Entity');

$object = new My\Entity();

// following will be VERY fast!
$hydrator->hydrate(array('foo' => 'bar'), $object);
var_dump($hydrator->extract($object)); // array('foo' => 'bar')
```

See the [complete documentation about generated hydrators](https://github.com/Ocramius/ProxyManager/tree/master/docs/generated-hydrator.md)
in the `docs/` directory.

## Contributing

Please read the [CONTRIBUTING.md](https://github.com/Ocramius/ProxyManager/blob/master/CONTRIBUTING.md) contents if you
wish to help out!

## Credits

The idea was originated by a [talk about Proxies in PHP OOP](http://marco-pivetta.com/proxy-pattern-in-php/) that I gave
at the [@phpugffm](https://twitter.com/phpugffm) in January 2013.
# GeneratedHydrator

Nothing to see here, move along!
26 changes: 11 additions & 15 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"name": "ocramius/proxy-manager",
"description": "A library providing utilities to generate, instantiate and generally operate with Object Proxies",
"name": "ocramius/generated-hydrator",
"description": "An Object Hydrator that allows very fast array to object to array conversion",
"type": "library",
"license": "MIT",
"homepage": "https://github.com/Ocramius/ProxyManager",
"homepage": "https://github.com/Ocramius/GeneratedHydrator",
"minimum-stability": "dev",
"keywords": [
"proxy",
"proxy pattern",
"service proxies",
"lazy loading",
"aop"
"hydrator",
"performance",
"array conversion",
"object conversion",
"serializer"
],
"authors": [
{
Expand All @@ -20,27 +20,23 @@
}
],
"require": {
"php": ">=5.3.3",
"zendframework/zend-code": "2.*"
"php": ">=5.4",
"zendframework/zend-stdlib": "2.*"
},
"require-dev": {
"phpunit/phpunit": ">=3.7",
"phpmd/phpmd": "1.4.*",
"squizlabs/php_codesniffer": "1.4.*",
"zendframework/zend-stdlib": "2.*",
"satooshi/php-coveralls": "~0.6"
},
"suggest": {
"zendframework/zend-stdlib": "To use the hydrator proxy"
},
"autoload": {
"psr-0": {
"ProxyManager\\": "src"
}
},
"extra": {
"branch-alias": {
"dev-master": "0.5.x-dev"
"dev-master": "1.0.x-dev"
}
}
}

0 comments on commit 78d5fd3

Please sign in to comment.