[fw-general] Re: autoloader example?

2012-10-15 Thread whisher
http://robertbasic.com/blog/using-the-new-autoloaders-from-zend-framework-1-12
http://robertbasic.com/blog/using-the-new-autoloaders-from-zend-framework-1-12
  



--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/autoloader-example-tp4657613p4657617.html
Sent from the Zend Framework mailing list archive at Nabble.com.

-- 
List: fw-general@lists.zend.com
Info: http://framework.zend.com/archives
Unsubscribe: fw-general-unsubscr...@lists.zend.com




Re: [fw-general] Re: autoloader example?

2012-10-15 Thread Tim
Thanks for the reply, it helped me get the autoloader working.

Follow-up question. I dont suppose it's possible to autoload ZF2
libraries, as well as ZF1 libraries in the same sentence is it?

something like

$var = new \Zend\Http\Client

and

$var2 = \Zend_Http_Client

Where the first example would load the ZF2 library and the second
would load the ZF1 library

Thoughts?

On Mon, Oct 15, 2012 at 1:33 PM, whisher whis...@maktoob.com wrote:
 http://robertbasic.com/blog/using-the-new-autoloaders-from-zend-framework-1-12
 http://robertbasic.com/blog/using-the-new-autoloaders-from-zend-framework-1-12



 --
 View this message in context: 
 http://zend-framework-community.634137.n4.nabble.com/autoloader-example-tp4657613p4657617.html
 Sent from the Zend Framework mailing list archive at Nabble.com.

 --
 List: fw-general@lists.zend.com
 Info: http://framework.zend.com/archives
 Unsubscribe: fw-general-unsubscr...@lists.zend.com



-- 
List: fw-general@lists.zend.com
Info: http://framework.zend.com/archives
Unsubscribe: fw-general-unsubscr...@lists.zend.com




[fw-general] Re: autoloader example?

2012-10-15 Thread luk
Tim Rupp wrote
 Thanks for the reply, it helped me get the autoloader working.
 
 Follow-up question. I dont suppose it's possible to autoload ZF2
 libraries, as well as ZF1 libraries in the same sentence is it?
 
 something like
 
 $var = new \Zend\Http\Client
 
 and
 
 $var2 = \Zend_Http_Client
 
 Where the first example would load the ZF2 library and the second
 would load the ZF1 library
 
 Thoughts?

You can still do that but you would need to register different namespace
namess for ZF1 and ZF2, for ie Zend and Zend2.



-
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/autoloader-example-tp4657613p4657620.html
Sent from the Zend Framework mailing list archive at Nabble.com.

-- 
List: fw-general@lists.zend.com
Info: http://framework.zend.com/archives
Unsubscribe: fw-general-unsubscr...@lists.zend.com




Re: [fw-general] Re: autoloader example?

2012-10-15 Thread Matthew Weier O'Phinney
-- Tim caphrim...@gmail.com wrote
(on Monday, 15 October 2012, 02:20 PM -0500):
 Thanks for the reply, it helped me get the autoloader working.
 
 Follow-up question. I dont suppose it's possible to autoload ZF2
 libraries, as well as ZF1 libraries in the same sentence is it?

Yes it is, actually.

You configure ZF2 via namespaces, and ZF1 via prefixes. You _must_,
however, not use the include_path for this to work.

So, as an example:

Zend_Loader_AutoloaderFactory::factory(array(
'Zend_Loader_StandardAutoloader' = array(
'namespaces' = array(
'Zend\\' = 'path/to/zf2/library/Zend',
),
'prefixes' = array(
'Zend_' = 'path/to/zf1/library/Zend',
),
),
));

Once you have, you can use components from each.

 something like
 
 $var = new \Zend\Http\Client
 
 and
 
 $var2 = \Zend_Http_Client
 
 Where the first example would load the ZF2 library and the second
 would load the ZF1 library
 
 Thoughts?
 
 On Mon, Oct 15, 2012 at 1:33 PM, whisher whis...@maktoob.com wrote:
  http://robertbasic.com/blog/using-the-new-autoloaders-from-zend-framework-1-12
  http://robertbasic.com/blog/using-the-new-autoloaders-from-zend-framework-1-12
 
 
 
  --
  View this message in context: 
  http://zend-framework-community.634137.n4.nabble.com/autoloader-example-tp4657613p4657617.html
  Sent from the Zend Framework mailing list archive at Nabble.com.
 
  --
  List: fw-general@lists.zend.com
  Info: http://framework.zend.com/archives
  Unsubscribe: fw-general-unsubscr...@lists.zend.com
 
 
 
 -- 
 List: fw-general@lists.zend.com
 Info: http://framework.zend.com/archives
 Unsubscribe: fw-general-unsubscr...@lists.zend.com
 
 

-- 
Matthew Weier O'Phinney
Project Lead| matt...@zend.com
Zend Framework  | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc

-- 
List: fw-general@lists.zend.com
Info: http://framework.zend.com/archives
Unsubscribe: fw-general-unsubscr...@lists.zend.com




Re: [fw-general] Re: autoloader example?

2012-10-15 Thread Tim
Thanks for the example Matthew, that pointed me further in the right
direction. I have this code which appears to run as I expect it to
run.



require_once '/lib/support/php/ZF2/Zend/Loader/AutoloaderFactory.php';

$paths = explode(PATH_SEPARATOR, get_include_path());
array_push($paths, '/lib/support/php');
array_push($paths, '/lib/support/php/ZF1');
set_include_path(implode(PATH_SEPARATOR, $paths));

$config = array(
'Zend\Loader\StandardAutoloader' = array(
'autoregister_zf' = true,
'namespaces' = array(
'Predis' = '/lib/support/php/Predis',
'Zend\\' = '/lib/support/php/ZF2/Zend',
),
'prefixes' = array(
'Zend_' = '/lib/support/php/ZF1/Zend'
),
'fallback_autoloader' = true
),
);
\Zend\Loader\AutoloaderFactory::factory($config);

$client1 = new \Zend_Http_Client;
$client2 = new \Zend\Http\Client;




And the objects and their types



Zend_Http_Client Object
(
[config:protected] = Array
(
...
)

Zend\Http\Client Object
(
[response:protected] =
[request:protected] =
...
)




You mentioned the importance of not using the include_path for the
dual stack usage, but I was having trouble getting it to work without
the configuration above.

Is this something I should be concerned about? Or am I fairly safe as
long as I'm explicit in using fully qualified namespaces and class
names?

Thanks,
Tim

On Mon, Oct 15, 2012 at 3:27 PM, Matthew Weier O'Phinney
matt...@zend.com wrote:
 -- Tim caphrim...@gmail.com wrote
 (on Monday, 15 October 2012, 02:20 PM -0500):
 Thanks for the reply, it helped me get the autoloader working.

 Follow-up question. I dont suppose it's possible to autoload ZF2
 libraries, as well as ZF1 libraries in the same sentence is it?

 Yes it is, actually.

 You configure ZF2 via namespaces, and ZF1 via prefixes. You _must_,
 however, not use the include_path for this to work.

 So, as an example:

 Zend_Loader_AutoloaderFactory::factory(array(
 'Zend_Loader_StandardAutoloader' = array(
 'namespaces' = array(
 'Zend\\' = 'path/to/zf2/library/Zend',
 ),
 'prefixes' = array(
 'Zend_' = 'path/to/zf1/library/Zend',
 ),
 ),
 ));

 Once you have, you can use components from each.

 something like

 $var = new \Zend\Http\Client

 and

 $var2 = \Zend_Http_Client

 Where the first example would load the ZF2 library and the second
 would load the ZF1 library

 Thoughts?

 On Mon, Oct 15, 2012 at 1:33 PM, whisher whis...@maktoob.com wrote:
  http://robertbasic.com/blog/using-the-new-autoloaders-from-zend-framework-1-12
  http://robertbasic.com/blog/using-the-new-autoloaders-from-zend-framework-1-12
 
 
 
  --
  View this message in context: 
  http://zend-framework-community.634137.n4.nabble.com/autoloader-example-tp4657613p4657617.html
  Sent from the Zend Framework mailing list archive at Nabble.com.
 
  --
  List: fw-general@lists.zend.com
  Info: http://framework.zend.com/archives
  Unsubscribe: fw-general-unsubscr...@lists.zend.com
 
 

 --
 List: fw-general@lists.zend.com
 Info: http://framework.zend.com/archives
 Unsubscribe: fw-general-unsubscr...@lists.zend.com



 --
 Matthew Weier O'Phinney
 Project Lead| matt...@zend.com
 Zend Framework  | http://framework.zend.com/
 PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc

 --
 List: fw-general@lists.zend.com
 Info: http://framework.zend.com/archives
 Unsubscribe: fw-general-unsubscr...@lists.zend.com



-- 
List: fw-general@lists.zend.com
Info: http://framework.zend.com/archives
Unsubscribe: fw-general-unsubscr...@lists.zend.com