How get Zend_Controller_Dispatcher_Token from index.php

23 messages Options
Embed this post
Permalink
1 2
Mauro Casula

How get Zend_Controller_Dispatcher_Token from index.php

Reply Threaded More More options
Print post
Permalink
Hi all,
I'm new of Zend Framework..

I need your help. I need to know how can i now what Zend_Controller_Dispatcher_Token i'm going to dispatch in my Index.php.

I need to know this because i'm developing an authentication system that will make the following:
$controller = Zend_Controller_Front::getInstance();
//AuthenticationController is my authentication class
$auth = AuthenticationController::factory($db,$session,$controller);

// if i have to authenticate:
$username = trim($post->noTags('username'));

if ($username!='') {
    $password= trim($post->noTags('password'));
    $auth->login($username, $password);
}

// i control from my class if the $token need authentication
// when the user is authenticated .. authRequired return false.


if ($auth->authRequired($token) == true) {
  // I store in Session where i was going..
  $session->__set('token',$token);
                 // I go to /login/login for display a form and put username and password...
                       $dispacher = new Zend_Controller_Dispatcher();
                $token = new Zend_Controller_Dispatcher_Token ("Login","login");
                $dispacher->setControllerDirectory('../app/controllers');
                $dispacher->dispatch($token);
}


....

I need to know the  Zend_Controller_Dispatcher_Token where i was going ...

I hope someone can help me with this issue..

Regards.

Mauro Casula
weierophinney

Re: How get Zend_Controller_Dispatcher_Token from index.php

Reply Threaded More More options
Print post
Permalink
-- Mauro Casula <[hidden email]> wrote
(on Monday, 13 November 2006, 02:55 AM -0800):
> I'm new of Zend Framework..
>
> I need your help. I need to know how can i now what
> Zend_Controller_Dispatcher_Token i'm going to dispatch in my Index.php.

First off, if you're new to ZF, don't use the controller classes in
core, use those in the incubator, as they are the next generation and
will be moved to core in the next release.

> I need to know this because i'm developing an authentication system that
> will make the following:
> $controller = Zend_Controller_Front::getInstance();
> //AuthenticationController is my authentication class
> $auth = AuthenticationController::factory($db,$session,$controller);
>
> // if i have to authenticate:
> $username = trim($post->noTags('username'));
>
> if ($username!='') {
>     $password= trim($post->noTags('password'));
>     $auth->login($username, $password);
> }
>
> // i control from my class if the $token need authentication
> // when the user is authenticated .. authRequired return false.
>
>
> if ($auth->authRequired($token) == true) {
>   // I store in Session where i was going..
>   $session->__set('token',$token);
>                  // I go to /login/login for display a form and put username
> and password...
>               $dispacher = new Zend_Controller_Dispatcher();
> $token = new Zend_Controller_Dispatcher_Token ("Login","login");
> $dispacher->setControllerDirectory('../app/controllers');
> $dispacher->dispatch($token);
> }

Simon Mundy gave a great example of how to integrate authentication with
the MVC components recently. Basically, you want to do the following:

    * Create a Plugin class extending Zend_Controller_Plugin_Abstract,
      and specifically override the preDispatch() method
    * Place your authentication criteria in the preDispatch() method:
      * Check against $this->getRequest()->getControllerName() and
        $this->getRequest()->getActionName() when validating an action
        against the credentials:

        $request    = $this->getRequest();
        $controller = $request->getControllerName();
        $action     = $request->getActionName();
        $if (!$auth->authRequired($controller, $action)) {
            // all okay...
        } else {
            // need authentication...
        }

      * Do the following if you need the user to login:
        $request = $this->getRequest();
        $request->setControllerName('login')
                ->setActionName('login')
                ->setDispatched(false);

Then, in your bootstrap (index.php), do the following:

    $controller = new Zend_Controller_Front();
    $controller->registerPlugin(new My_Controller_Plugins())
               ->setParam('session', $session)
               ->setParam('db', $db)
               ->setControllerDirectory('../app/controllers');
    $controller->dispatch();

--
Matthew Weier O'Phinney
PHP Developer            | [hidden email]
Zend - The PHP Company   | http://www.zend.com/
Mauro Casula

Re: How get Zend_Controller_Dispatcher_Token from index.php

Reply Threaded More More options
Print post
Permalink
I have undestand the mechanism you suggest and i'm trying to implement that..

But I have a question.
I have to write  myself this method you have suggest ?

> $this->getRequest();

Extending the abstract class of Plugin i dont have this method..



Thank you very much for your patience.
Sorry for my bad english and for my stupid questions..
weierophinney

Re: How get Zend_Controller_Dispatcher_Token from index.php

Reply Threaded More More options
Print post
Permalink
-- Mauro Casula <[hidden email]> wrote
(on Monday, 13 November 2006, 08:06 AM -0800):
> I have undestand the mechanism you suggest and i'm trying to implement that..
>
> But I have a question.
> I have to write  myself this method you have suggest ?
>
> > $this->getRequest();
>
> Extending the abstract class of Plugin i dont have this method..

Again, you need to use the MVC components in the incubator; make sure
that the incubator/library/ path is before the library/ path when you
set the include_path. Zend_Controller_Plugin_Abstract::getRequest()
exists in the incubator version.

--
Matthew Weier O'Phinney
PHP Developer            | [hidden email]
Zend - The PHP Company   | http://www.zend.com/
Mauro Casula

Re: How get Zend_Controller_Dispatcher_Token from index.php

Reply Threaded More More options
Print post
Permalink
I have put in my  php.ini:

include_path = ".;C:\Programmi\php\ext;C:\Programmi\php\ext\incubator;C:\Programmi\php\ext\core"

inside incubator there in Zend.php of the incubator
inside core Zend.php of core.

I think there is something that i dont know because when i restart Apache and start the application
i get the error that its impossible to found Zend_registry...

... what i have to do?

Regards.

Mauro Casula.

Matthew Weier O wrote:
-- Mauro Casula <maurocasula@gmail.com> wrote
(on Monday, 13 November 2006, 08:06 AM -0800):
> I have undestand the mechanism you suggest and i'm trying to implement that..
>
> But I have a question.
> I have to write  myself this method you have suggest ?
>
> > $this->getRequest();
>
> Extending the abstract class of Plugin i dont have this method..

Again, you need to use the MVC components in the incubator; make sure
that the incubator/library/ path is before the library/ path when you
set the include_path. Zend_Controller_Plugin_Abstract::getRequest()
exists in the incubator version.

--
Matthew Weier O'Phinney
PHP Developer            | matthew@zend.com
Zend - The PHP Company   | http://www.zend.com/
Basil Mohamed Gohar

Re: How get Zend_Controller_Dispatcher_Token from index.php

Reply Threaded More More options
Print post
Permalink
Mauro,

I think you need to be including the /library/ directory of both the
incubator and the core, not just the entire Zend directory or Zend.php.

So, for example, if you have the zend framework release in the directory
C:\Programmi\zf-release-0.2.0, then you want to include in PHP
C:\Programmi\zf-release-0.2.0\library.  Always include the /library/
directory.

I hope this helps!

Mauro Casula wrote:

> I have put in my  php.ini:
>
> include_path =
> ".;C:\Programmi\php\ext;C:\Programmi\php\ext\incubator;C:\Programmi\php\ext\core"
>
> inside incubator there in Zend.php of the incubator
> inside core Zend.php of core.
>
> I think there is something that i dont know because when i restart Apache
> and start the application
> i get the error that its impossible to found Zend_registry...
>
> ... what i have to do?
>
> Regards.
>
> Mauro Casula.
>
>
> Matthew Weier O wrote:
>  
>> -- Mauro Casula <[hidden email]> wrote
>> (on Monday, 13 November 2006, 08:06 AM -0800):
>>    
>>> I have undestand the mechanism you suggest and i'm trying to implement
>>> that..
>>>
>>> But I have a question.
>>> I have to write  myself this method you have suggest ?
>>>
>>>      
>>>> $this->getRequest();
>>>>        
>>> Extending the abstract class of Plugin i dont have this method..
>>>      
>> Again, you need to use the MVC components in the incubator; make sure
>> that the incubator/library/ path is before the library/ path when you
>> set the include_path. Zend_Controller_Plugin_Abstract::getRequest()
>> exists in the incubator version.
>>
>> --
>> Matthew Weier O'Phinney
>> PHP Developer            | [hidden email]
>> Zend - The PHP Company   | http://www.zend.com/
>>
>>
>>    
>
>  
Mauro Casula

Re: How get Zend_Controller_Dispatcher_Token from index.php

Reply Threaded More More options
Print post
Permalink
Hi,
thank you for your help..

I have in C:\Programmi\php\ext\incubator
Zend.php of incubator and all the library of incubator and in
C:\Programmi\php\ext\core
Zend.php of core and all the library of core.

The application run without problems if i put:
 ".;C:\Programmi\php\ext;C:\Programmi\php\ext\core;C:\Programmi\php\ext\incubator"

But I need to use the new classes of incubator... I dont know how to use this new classes...

I hope that i have explained better my problem...


Thank you all for your help.
Mauro Casula.

Abu Hurayrah-2 wrote:
Mauro,

I think you need to be including the /library/ directory of both the
incubator and the core, not just the entire Zend directory or Zend.php.

So, for example, if you have the zend framework release in the directory
C:\Programmi\zf-release-0.2.0, then you want to include in PHP
C:\Programmi\zf-release-0.2.0\library.  Always include the /library/
directory.

I hope this helps!

Mauro Casula wrote:
> I have put in my  php.ini:
>
> include_path =
> ".;C:\Programmi\php\ext;C:\Programmi\php\ext\incubator;C:\Programmi\php\ext\core"
>
> inside incubator there in Zend.php of the incubator
> inside core Zend.php of core.
>
> I think there is something that i dont know because when i restart Apache
> and start the application
> i get the error that its impossible to found Zend_registry...
>
> ... what i have to do?
>
> Regards.
>
> Mauro Casula.
>
>
> Matthew Weier O wrote:
>  
>> -- Mauro Casula <maurocasula@gmail.com> wrote
>> (on Monday, 13 November 2006, 08:06 AM -0800):
>>    
>>> I have undestand the mechanism you suggest and i'm trying to implement
>>> that..
>>>
>>> But I have a question.
>>> I have to write  myself this method you have suggest ?
>>>
>>>      
>>>> $this->getRequest();
>>>>        
>>> Extending the abstract class of Plugin i dont have this method..
>>>      
>> Again, you need to use the MVC components in the incubator; make sure
>> that the incubator/library/ path is before the library/ path when you
>> set the include_path. Zend_Controller_Plugin_Abstract::getRequest()
>> exists in the incubator version.
>>
>> --
>> Matthew Weier O'Phinney
>> PHP Developer            | matthew@zend.com
>> Zend - The PHP Company   | http://www.zend.com/
>>
>>
>>    
>
>  
Matthew Ratzloff

Re: How get Zend_Controller_Dispatcher_Token from index.php

Reply Threaded More More options
Print post
Permalink
Mauro,

Instead of
".;C:\Programmi\php\ext;C:\Programmi\php\ext\core;C:\Programmi\php\ext\incubator"

Use
".;C:\Programmi\php\ext;C:\Programmi\php\ext\incubator;C:\Programmi\php\ext\core"

In other words, swap the position of incubator and core files so that PHP
looks in the incubator before it looks in core.

However, I would recommend setting this dynamically at the top of your
bootstrap file instead, and keeping the directory structure of the
framework so you can easily update it.  You may also want multiple copies
of the framework so you can update one application at a time instead of
all at once.

Hope that helps,

-Matt

> Hi,
> thank you for your help..
>
> I have in C:\Programmi\php\ext\incubator
> Zend.php of incubator and all the library of incubator and in
> C:\Programmi\php\ext\core
> Zend.php of core and all the library of core.
>
> The application run without problems if i put:
>
> ".;C:\Programmi\php\ext;C:\Programmi\php\ext\core;C:\Programmi\php\ext\incubator"
>
> But I need to use the new classes of incubator... I dont know how to use
> this new classes...
>
> I hope that i have explained better my problem...
>
>
> Thank you all for your help.
> Mauro Casula.
>
>
> Abu Hurayrah-2 wrote:
>>
>> Mauro,
>>
>> I think you need to be including the /library/ directory of both the
>> incubator and the core, not just the entire Zend directory or Zend.php.
>>
>> So, for example, if you have the zend framework release in the directory
>> C:\Programmi\zf-release-0.2.0, then you want to include in PHP
>> C:\Programmi\zf-release-0.2.0\library.  Always include the /library/
>> directory.
>>
>> I hope this helps!
>>
>> Mauro Casula wrote:
>>> I have put in my  php.ini:
>>>
>>> include_path =
>>> ".;C:\Programmi\php\ext;C:\Programmi\php\ext\incubator;C:\Programmi\php\ext\core"
>>>
>>> inside incubator there in Zend.php of the incubator
>>> inside core Zend.php of core.
>>>
>>> I think there is something that i dont know because when i restart
>>> Apache
>>> and start the application
>>> i get the error that its impossible to found Zend_registry...
>>>
>>> ... what i have to do?
>>>
>>> Regards.
>>>
>>> Mauro Casula.
>>>
>>>
>>> Matthew Weier O wrote:
>>>
>>>> -- Mauro Casula <[hidden email]> wrote
>>>> (on Monday, 13 November 2006, 08:06 AM -0800):
>>>>
>>>>> I have undestand the mechanism you suggest and i'm trying to
>>>>> implement
>>>>> that..
>>>>>
>>>>> But I have a question.
>>>>> I have to write  myself this method you have suggest ?
>>>>>
>>>>>
>>>>>> $this->getRequest();
>>>>>>
>>>>> Extending the abstract class of Plugin i dont have this method..
>>>>>
>>>> Again, you need to use the MVC components in the incubator; make sure
>>>> that the incubator/library/ path is before the library/ path when you
>>>> set the include_path. Zend_Controller_Plugin_Abstract::getRequest()
>>>> exists in the incubator version.
>>>>
>>>> --
>>>> Matthew Weier O'Phinney
>>>> PHP Developer            | [hidden email]
>>>> Zend - The PHP Company   | http://www.zend.com/
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
> --
> View this message in context:
> http://www.nabble.com/How-get-Zend_Controller_Dispatcher_Token-from-index.php-tf2621448s16154.html#a7323003
> Sent from the Zend Framework mailing list archive at Nabble.com.
>
>


Darby Felton

Re: How get Zend_Controller_Dispatcher_Token from index.php

Reply Threaded More More options
Print post
Permalink
Hi all,

Here is another idea for integrating your applications with Zend
Framework; I hope it is useful to someone.

If you manage your application code in Subversion (SVN), you can use the
handy "svn:externals" property to manage your application's use of the
Zend Framework:

http://svnbook.red-bean.com/nightly/en/svn.advanced.props.html#svn.advanced.props.special.externals

or, tinyurl:

http://tinyurl.com/yfvbou

In this way, you have complete control of each application's use of the
Zend Framework. It gives you the ability to update each application
separately, and it lets you set the /version/ of the framework code on a
per-application basis.

Your mileage may vary, of course, depending on the availability of
various systems to you (e.g., a Subversion-capable server).

Best regards,
Darby

Matthew Ratzloff wrote:

> Mauro,
>
> Instead of
> ".;C:\Programmi\php\ext;C:\Programmi\php\ext\core;C:\Programmi\php\ext\incubator"
>
> Use
> ".;C:\Programmi\php\ext;C:\Programmi\php\ext\incubator;C:\Programmi\php\ext\core"
>
> In other words, swap the position of incubator and core files so that PHP
> looks in the incubator before it looks in core.
>
> However, I would recommend setting this dynamically at the top of your
> bootstrap file instead, and keeping the directory structure of the
> framework so you can easily update it.  You may also want multiple copies
> of the framework so you can update one application at a time instead of
> all at once.
>
> Hope that helps,
>
> -Matt
>
>> Hi,
>> thank you for your help..
>>
>> I have in C:\Programmi\php\ext\incubator
>> Zend.php of incubator and all the library of incubator and in
>> C:\Programmi\php\ext\core
>> Zend.php of core and all the library of core.
>>
>> The application run without problems if i put:
>>
>> ".;C:\Programmi\php\ext;C:\Programmi\php\ext\core;C:\Programmi\php\ext\incubator"
>>
>> But I need to use the new classes of incubator... I dont know how to use
>> this new classes...
>>
>> I hope that i have explained better my problem...
>>
>>
>> Thank you all for your help.
>> Mauro Casula.
>>
>>
>> Abu Hurayrah-2 wrote:
>>> Mauro,
>>>
>>> I think you need to be including the /library/ directory of both the
>>> incubator and the core, not just the entire Zend directory or Zend.php.
>>>
>>> So, for example, if you have the zend framework release in the directory
>>> C:\Programmi\zf-release-0.2.0, then you want to include in PHP
>>> C:\Programmi\zf-release-0.2.0\library.  Always include the /library/
>>> directory.
>>>
>>> I hope this helps!
>>>
>>> Mauro Casula wrote:
>>>> I have put in my  php.ini:
>>>>
>>>> include_path =
>>>> ".;C:\Programmi\php\ext;C:\Programmi\php\ext\incubator;C:\Programmi\php\ext\core"
>>>>
>>>> inside incubator there in Zend.php of the incubator
>>>> inside core Zend.php of core.
>>>>
>>>> I think there is something that i dont know because when i restart
>>>> Apache
>>>> and start the application
>>>> i get the error that its impossible to found Zend_registry...
>>>>
>>>> ... what i have to do?
>>>>
>>>> Regards.
>>>>
>>>> Mauro Casula.
>>>>
>>>>
>>>> Matthew Weier O wrote:
>>>>
>>>>> -- Mauro Casula <[hidden email]> wrote
>>>>> (on Monday, 13 November 2006, 08:06 AM -0800):
>>>>>
>>>>>> I have undestand the mechanism you suggest and i'm trying to
>>>>>> implement
>>>>>> that..
>>>>>>
>>>>>> But I have a question.
>>>>>> I have to write  myself this method you have suggest ?
>>>>>>
>>>>>>
>>>>>>> $this->getRequest();
>>>>>>>
>>>>>> Extending the abstract class of Plugin i dont have this method..
>>>>>>
>>>>> Again, you need to use the MVC components in the incubator; make sure
>>>>> that the incubator/library/ path is before the library/ path when you
>>>>> set the include_path. Zend_Controller_Plugin_Abstract::getRequest()
>>>>> exists in the incubator version.
>>>>>
>>>>> --
>>>>> Matthew Weier O'Phinney
>>>>> PHP Developer            | [hidden email]
>>>>> Zend - The PHP Company   | http://www.zend.com/
>>>>>
>>>>>
>>>>>
>>>>
>>>
>> --
>> View this message in context:
>> http://www.nabble.com/How-get-Zend_Controller_Dispatcher_Token-from-index.php-tf2621448s16154.html#a7323003
>> Sent from the Zend Framework mailing list archive at Nabble.com.
>>
>>
>
>
>
Basil Mohamed Gohar

Re: How get Zend_Controller_Dispatcher_Token from index.php

Reply Threaded More More options
Print post
Permalink
I considered this method myself for my own projects, but the amount of
time it would take to the normal checkout/update/commit cycle seemed a
bit excessive.  Additionally, in this thread, we'd have to deal with two
separate branches of the entire framework - library under both trunk &
incubator.

Perhaps for a release that is pegged to a specific tag, it would make
more sense, but for development, it seems like an awful lot of work.  Am
I being too critical?

Darby Felton wrote:

> Hi all,
>
> Here is another idea for integrating your applications with Zend
> Framework; I hope it is useful to someone.
>
> If you manage your application code in Subversion (SVN), you can use the
> handy "svn:externals" property to manage your application's use of the
> Zend Framework:
>
> http://svnbook.red-bean.com/nightly/en/svn.advanced.props.html#svn.advanced.props.special.externals
>
> or, tinyurl:
>
> http://tinyurl.com/yfvbou
>
> In this way, you have complete control of each application's use of the
> Zend Framework. It gives you the ability to update each application
> separately, and it lets you set the /version/ of the framework code on a
> per-application basis.
>
> Your mileage may vary, of course, depending on the availability of
> various systems to you (e.g., a Subversion-capable server).
>
> Best regards,
> Darby
>
> Matthew Ratzloff wrote:
>  
>> Mauro,
>>
>> Instead of
>> ".;C:\Programmi\php\ext;C:\Programmi\php\ext\core;C:\Programmi\php\ext\incubator"
>>
>> Use
>> ".;C:\Programmi\php\ext;C:\Programmi\php\ext\incubator;C:\Programmi\php\ext\core"
>>
>> In other words, swap the position of incubator and core files so that PHP
>> looks in the incubator before it looks in core.
>>
>> However, I would recommend setting this dynamically at the top of your
>> bootstrap file instead, and keeping the directory structure of the
>> framework so you can easily update it.  You may also want multiple copies
>> of the framework so you can update one application at a time instead of
>> all at once.
>>
>> Hope that helps,
>>
>> -Matt
>>
>>    
>>> Hi,
>>> thank you for your help..
>>>
>>> I have in C:\Programmi\php\ext\incubator
>>> Zend.php of incubator and all the library of incubator and in
>>> C:\Programmi\php\ext\core
>>> Zend.php of core and all the library of core.
>>>
>>> The application run without problems if i put:
>>>
>>> ".;C:\Programmi\php\ext;C:\Programmi\php\ext\core;C:\Programmi\php\ext\incubator"
>>>
>>> But I need to use the new classes of incubator... I dont know how to use
>>> this new classes...
>>>
>>> I hope that i have explained better my problem...
>>>
>>>
>>> Thank you all for your help.
>>> Mauro Casula.
>>>
>>>
>>> Abu Hurayrah-2 wrote:
>>>      
>>>> Mauro,
>>>>
>>>> I think you need to be including the /library/ directory of both the
>>>> incubator and the core, not just the entire Zend directory or Zend.php.
>>>>
>>>> So, for example, if you have the zend framework release in the directory
>>>> C:\Programmi\zf-release-0.2.0, then you want to include in PHP
>>>> C:\Programmi\zf-release-0.2.0\library.  Always include the /library/
>>>> directory.
>>>>
>>>> I hope this helps!
>>>>
>>>> Mauro Casula wrote:
>>>>        
>>>>> I have put in my  php.ini:
>>>>>
>>>>> include_path =
>>>>> ".;C:\Programmi\php\ext;C:\Programmi\php\ext\incubator;C:\Programmi\php\ext\core"
>>>>>
>>>>> inside incubator there in Zend.php of the incubator
>>>>> inside core Zend.php of core.
>>>>>
>>>>> I think there is something that i dont know because when i restart
>>>>> Apache
>>>>> and start the application
>>>>> i get the error that its impossible to found Zend_registry...
>>>>>
>>>>> ... what i have to do?
>>>>>
>>>>> Regards.
>>>>>
>>>>> Mauro Casula.
>>>>>
>>>>>
>>>>> Matthew Weier O wrote:
>>>>>
>>>>>          
>>>>>> -- Mauro Casula <[hidden email]> wrote
>>>>>> (on Monday, 13 November 2006, 08:06 AM -0800):
>>>>>>
>>>>>>            
>>>>>>> I have undestand the mechanism you suggest and i'm trying to
>>>>>>> implement
>>>>>>> that..
>>>>>>>
>>>>>>> But I have a question.
>>>>>>> I have to write  myself this method you have suggest ?
>>>>>>>
>>>>>>>
>>>>>>>              
>>>>>>>> $this->getRequest();
>>>>>>>>
>>>>>>>>                
>>>>>>> Extending the abstract class of Plugin i dont have this method..
>>>>>>>
>>>>>>>              
>>>>>> Again, you need to use the MVC components in the incubator; make sure
>>>>>> that the incubator/library/ path is before the library/ path when you
>>>>>> set the include_path. Zend_Controller_Plugin_Abstract::getRequest()
>>>>>> exists in the incubator version.
>>>>>>
>>>>>> --
>>>>>> Matthew Weier O'Phinney
>>>>>> PHP Developer            | [hidden email]
>>>>>> Zend - The PHP Company   | http://www.zend.com/
>>>>>>
>>>>>>
>>>>>>
>>>>>>            
>>> --
>>> View this message in context:
>>> http://www.nabble.com/How-get-Zend_Controller_Dispatcher_Token-from-index.php-tf2621448s16154.html#a7323003
>>> Sent from the Zend Framework mailing list archive at Nabble.com.
>>>
>>>
>>>      
>>
>>    
Simon Mundy

Re: How get Zend_Controller_Dispatcher_Token from index.php

Reply Threaded More More options
Print post
Permalink
I guess it depends on how frequently you maintain your projects. I've  
got some that require weekly maintenance and others that won't change  
for months. It seems easier for me to publish a project 'snapshot'  
and know that further updates to the Zend Framework won't break them  
unexpectedly or require a lot of work to bring it back into line - a  
good example here is two projects I have with the new MVC and a whole  
bunch of others that aren't. It would allow me to maintain all sites  
with my own framework additions and not need to worry about major  
rewrites too often (Zend_Config, for example! :-)

Thanks for the heads-up Darby

> I considered this method myself for my own projects, but the amount  
> of time it would take to the normal checkout/update/commit cycle  
> seemed a bit excessive.  Additionally, in this thread, we'd have to  
> deal with two separate branches of the entire framework - library  
> under both trunk & incubator.
>
> Perhaps for a release that is pegged to a specific tag, it would  
> make more sense, but for development, it seems like an awful lot of  
> work.  Am I being too critical?

--

Simon Mundy | Director | PEPTOLAB

""" " "" """""" "" "" """"""" " "" """"" " """"" "  """""" "" "
202/258 Flinders Lane | Melbourne | Victoria | Australia | 3000
Voice +61 (0) 3 9654 4324 | Mobile 0438 046 061 | Fax +61 (0) 3 9654  
4124
http://www.peptolab.com


weierophinney

Re: How get Zend_Controller_Dispatcher_Token from index.php

Reply Threaded More More options
Print post
Permalink
In reply to this post by Mauro Casula
-- Mauro Casula <[hidden email]> wrote
(on Monday, 13 November 2006, 10:46 AM -0800):
> I have in C:\Programmi\php\ext\incubator
> Zend.php of incubator and all the library of incubator and in
> C:\Programmi\php\ext\core
> Zend.php of core and all the library of core.
>
> The application run without problems if i put:
>
> ".;C:\Programmi\php\ext;C:\Programmi\php\ext\core;C:\Programmi\php\ext\incubator"

Let's say that you have unzipped the 0.2.0 release (or checked out
current svn) to "C:\Programmi\php\zend_framework". Assuming you don't
need any other libraries in your path (such as PEAR), your path would
look like this:

    .;C:\Programmi\php\zend_framework\incubator\library;C:\Programmi\php\zend_framework\library

This gives precedence to the incubator classes. Note that, in both the
incubator and core cases, the final segment of the path is 'library' --
this is where the actual classes are located.

--
Matthew Weier O'Phinney
PHP Developer            | [hidden email]
Zend - The PHP Company   | http://www.zend.com/
Mauro Casula

Re: How get Zend_Controller_Dispatcher_Token from index.php

Reply Threaded More More options
Print post
Permalink
I have followed your suggestions but i get this error:

Fatal error: Class 'Zend_Registry' not found in C:\Programmi\php\Zend\incubator\library\Zend.php on line 284

I dont know what is wrong..

I have to change work? :)

I have not wrong with the paths.. i'm shure of that...

Anyone know why i have this error?

Thank you very much!

Mauro.


Matthew Weier O wrote:
-- Mauro Casula <maurocasula@gmail.com> wrote
(on Monday, 13 November 2006, 10:46 AM -0800):
> I have in C:\Programmi\php\ext\incubator
> Zend.php of incubator and all the library of incubator and in
> C:\Programmi\php\ext\core
> Zend.php of core and all the library of core.
>
> The application run without problems if i put:
>
> ".;C:\Programmi\php\ext;C:\Programmi\php\ext\core;C:\Programmi\php\ext\incubator"

Let's say that you have unzipped the 0.2.0 release (or checked out
current svn) to "C:\Programmi\php\zend_framework". Assuming you don't
need any other libraries in your path (such as PEAR), your path would
look like this:

    .;C:\Programmi\php\zend_framework\incubator\library;C:\Programmi\php\zend_framework\library

This gives precedence to the incubator classes. Note that, in both the
incubator and core cases, the final segment of the path is 'library' --
this is where the actual classes are located.

--
Matthew Weier O'Phinney
PHP Developer            | matthew@zend.com
Zend - The PHP Company   | http://www.zend.com/
weierophinney

Re: How get Zend_Controller_Dispatcher_Token from index.php

Reply Threaded More More options
Print post
Permalink
-- Mauro Casula <[hidden email]> wrote
(on Monday, 13 November 2006, 11:40 AM -0800):
> I have followed your suggestions but i get this error:
>
> Fatal error: Class 'Zend_Registry' not found in
> C:\Programmi\php\Zend\incubator\library\Zend.php on line 284

There was an include that was missing in the incubator Zend.php shipped with
0.2.0. Add this line into incubator/library/Zend.php:

    require_once 'Zend/Registry.php';

somewhere near the top of the file, and you should be okay.


--
Matthew Weier O'Phinney
PHP Developer            | [hidden email]
Zend - The PHP Company   | http://www.zend.com/
Mauro Casula

Re: How get Zend_Controller_Dispatcher_Token from index.php

Reply Threaded More More options
Print post
Permalink
Adding
    require_once 'Zend/Registry.php';
this error disappear.. but i have this:

Fatal error: Call to undefined method Zend_Controller_Front::getinstance() in C:\Progetti\Kettler\SITE\kettler\www\index.php on line 68

So i have sobstitute in my index.php:
   $controller = Zend_Controller_Front::getInstance();
with:
  $controller = new Zend_Controller_Front();

but in this case i get this error:

Fatal error: Call to undefined method ReflectionClass::newInstanceArgs() in C:\Programmi\php\Zend\incubator\library\Zend\Controller\Dispatcher.php on line 391

I think that i'm too much dependent on Core classes...

Anyone know what can be the problem?

Regards.

Mauro Casula.



Matthew Weier O wrote:
-- Mauro Casula <maurocasula@gmail.com> wrote
(on Monday, 13 November 2006, 11:40 AM -0800):
> I have followed your suggestions but i get this error:
>
> Fatal error: Class 'Zend_Registry' not found in
> C:\Programmi\php\Zend\incubator\library\Zend.php on line 284

There was an include that was missing in the incubator Zend.php shipped with
0.2.0. Add this line into incubator/library/Zend.php:

    require_once 'Zend/Registry.php';

somewhere near the top of the file, and you should be okay.


--
Matthew Weier O'Phinney
PHP Developer            | matthew@zend.com
Zend - The PHP Company   | http://www.zend.com/
weierophinney

Re: How get Zend_Controller_Dispatcher_Token from index.php

Reply Threaded More More options
Print post
Permalink
-- Mauro Casula <[hidden email]> wrote
(on Tuesday, 14 November 2006, 03:05 AM -0800):

> Adding
>     require_once 'Zend/Registry.php';
> this error disappear.. but i have this:
>
> Fatal error: Call to undefined method Zend_Controller_Front::getinstance()
> in C:\Progetti\Kettler\SITE\kettler\www\index.php on line 68
>
> So i have sobstitute in my index.php:
>    $controller = Zend_Controller_Front::getInstance();
> with:
>   $controller = new Zend_Controller_Front();

getInstance() was removed in the incubator component. Basically, we saw
no reason to force a singleton instance, and having the singleton
resulted in a testing nightmare.

> but in this case i get this error:
>
> Fatal error: Call to undefined method ReflectionClass::newInstanceArgs() in
> C:\Programmi\php\Zend\incubator\library\Zend\Controller\Dispatcher.php on
> line 391
>
> I think that i'm too much dependent on Core classes...
>
> Anyone know what can be the problem?

Yep. Upgrade your PHP version to at least 5.1.4, which is the minimum
supported version for framework. The method you indicate above,
ReflectionClass::newInstanceArgs(), is part of PHP's Reflection API, and
needs to be present for the current version of the dispatcher to work.
To my knowledge, it's been in PHP since 5.1.2.


--
Matthew Weier O'Phinney
PHP Developer            | [hidden email]
Zend - The PHP Company   | http://www.zend.com/
Mauro Casula

Re: How get Zend_Controller_Dispatcher_Token from index.php

Reply Threaded More More options
Print post
Permalink
I have upgraded PHP...
Now the application doesnt return errors but only the index action is showed.

Is this code correct?

        $controller = new Zend_Controller_Front();
    $controller->registerPlugin(new AuthPlugin($db,$session,$post))
               ->setControllerDirectory('../app/controllers');
    $controller->dispatch();








Matthew Weier O wrote:
-- Mauro Casula <maurocasula@gmail.com> wrote
(on Tuesday, 14 November 2006, 03:05 AM -0800):
> Adding
>     require_once 'Zend/Registry.php';
> this error disappear.. but i have this:
>
> Fatal error: Call to undefined method Zend_Controller_Front::getinstance()
> in C:\Progetti\Kettler\SITE\kettler\www\index.php on line 68
>
> So i have sobstitute in my index.php:
>    $controller = Zend_Controller_Front::getInstance();
> with:
>   $controller = new Zend_Controller_Front();

getInstance() was removed in the incubator component. Basically, we saw
no reason to force a singleton instance, and having the singleton
resulted in a testing nightmare.

> but in this case i get this error:
>
> Fatal error: Call to undefined method ReflectionClass::newInstanceArgs() in
> C:\Programmi\php\Zend\incubator\library\Zend\Controller\Dispatcher.php on
> line 391
>
> I think that i'm too much dependent on Core classes...
>
> Anyone know what can be the problem?

Yep. Upgrade your PHP version to at least 5.1.4, which is the minimum
supported version for framework. The method you indicate above,
ReflectionClass::newInstanceArgs(), is part of PHP's Reflection API, and
needs to be present for the current version of the dispatcher to work.
To my knowledge, it's been in PHP since 5.1.2.


--
Matthew Weier O'Phinney
PHP Developer            | matthew@zend.com
Zend - The PHP Company   | http://www.zend.com/
Pádraic Brady

Re: How get Zend_Controller_Dispatcher_Token from index.php

Reply Threaded More More options
Print post
Permalink
In reply to this post by Mauro Casula
Some javascript/style in this post has been disabled (why?)
Reading back, you seem to be using the Incubator Classes. Same thing for Incubator is (assuming you're using a Response object):

/*
 * Instantiate a Request to set BaseURL
 * See later...
 */
$request = new Zend_Controller_Request_Http();

/*
 * Instantiate a RewriteRouter
 */
$router = new Zend_Controller_RewriteRouter();

/*
 * On my platform, I need to set the BaseURL for ZF 0.20
 * RewriteBase is assumed to be $_SERVER['PHP_SELF'] after
 * removing the trailing "index.php" string.
 *
 * PHP_SELF can be user manipulated. Avoided using SCRIPT_NAME
 * or SCRIPT_FILENAME because they may differ depending on SAPI
 * being used.
 */
$base_url = substr($_SERVER['PHP_SELF'], 0, -9);
$request->setBaseUrl($base_url);

/*
 * Setup and run the Front Controller
 *
 * Set Controller Dir, add the RewriteRouter, dispatch the
 * modified Request (with updated BaseURL) and finally
 * get the resulting Response object.
 */
$controller = new Zend_Controller_Front;
$controller->setControllerDirectory('./application/controllers');
$controller->setRouter($router);
$response = $controller->dispatch($request);

/*
 * By default Exceptions are not displayed
 * That won't do during development.
 * Remove this in a live environment!
 *
 * $response->renderExceptions(true); will not
 * work, it's a bit broken and was fixed in SVN for
 * next release. Until then...manually echo exception
 */
if($response->isException())
{
    echo $response->getException();
    exit; // Stop here - ;)
}

/*
 * Echo the response (with headers) to client
 * Zend_Controller_Response_Http implements
 * __toString().
 */
echo $response;


This should work just fine. Be better once 0.21 is out with a few fixes ;).

Paddy


 


Pádraic Brady
http://blog.quantum-star.com
http://www.patternsforphp.com


----- Original Message ----
From: "[hidden email]" <[hidden email]>
To: Zend Framework General <[hidden email]>
Sent: Tuesday, November 14, 2006 1:55:29 PM
Subject: Re: [fw-general] How get Zend_Controller_Dispatcher_Token from index.php

Hi,

If you have the application in a subdirectory (not webroot) then you may need to set a rewrite base (if using Core) or base url (with Incubator).

Usually it's something like:

$router = new Zend_Controller_RewriteRouter;
/*
 * On my platform, I need to set the RewriteBase for ZF 0.20
 * RewriteBase is assumed to be $_SERVER['PHP_SELF'] after
 * removing the trailing "index.php" string
 */
$rewrite_base = substr($_SERVER['PHP_SELF'], 0, -9);
$router->setRewriteBase($rewrite_base);

//... other controller setup in here

$controller->setRouter($router);

The rest is the same as you have...

If you're using the MVC classes in the incubator directory the process is different (let us know).

Regards,
Pádraic
 


Pádraic Brady
http://blog.quantum-star.com
http://www.patternsforphp.com


----- Original Message ----
From: Mauro Casula <[hidden email]>
To: [hidden email]
Sent: Tuesday, November 14, 2006 1:38:48 PM
Subject: Re: [fw-general] How get Zend_Controller_Dispatcher_Token from index.php


I have upgraded PHP...
Now the application doesnt return errors but only the index action is
showed.

Is this code correct?

    $controller = new Zend_Controller_Front();
    $controller->registerPlugin(new AuthPlugin($db,$session,$post))
               ->setControllerDirectory('../app/controllers');
    $controller->dispatch();









Matthew Weier O wrote:

>
> -- Mauro Casula <[hidden email]> wrote
> (on Tuesday, 14 November 2006, 03:05 AM -0800):
>> Adding
>>     require_once 'Zend/Registry.php';
>> this error disappear.. but i have this:
>>
>> Fatal error: Call to undefined method
>> Zend_Controller_Front::getinstance()
>> in C:\Progetti\Kettler\SITE\kettler\www\index.php on line 68
>>
>> So i have sobstitute in my index.php:
>>    $controller = Zend_Controller_Front::getInstance();
>> with:
>>   $controller = new Zend_Controller_Front();
>
> getInstance() was removed in the incubator component. Basically, we saw
> no reason to force a singleton instance, and having the singleton
> resulted in a testing nightmare.
>
>> but in this case i get this error:
>>
>> Fatal error: Call to undefined method ReflectionClass::newInstanceArgs()
>> in
>> C:\Programmi\php\Zend\incubator\library\Zend\Controller\Dispatcher.php on
>> line 391
>>
>> I think that i'm too much dependent on Core classes...
>>
>> Anyone know what can be the problem?
>
> Yep. Upgrade your PHP version to at least 5.1.4, which is the minimum
> supported version for framework. The method you indicate above,
> ReflectionClass::newInstanceArgs(), is part of PHP's Reflection API, and
> needs to be present for the current version of the dispatcher to work.
> To my knowledge, it's been in PHP since 5.1.2.
>
>
> --
> Matthew Weier O'Phinney
> PHP Developer            | [hidden email]
> Zend - The PHP Company   | http://www.zend.com/
>
>

--
View this message in context: http://www.nabble.com/How-get-Zend_Controller_Dispatcher_Token-from-index.php-tf2621448s16154.html#a7337670
Sent from the Zend Framework mailing list archive at Nabble.com.




Everyone is raving about the all-new Yahoo! Mail beta.



Cheap Talk? Check out Yahoo! Messenger's low PC-to-Phone call rates.
Pádraic Brady

Re: How get Zend_Controller_Dispatcher_Token from index.php

Reply Threaded More More options
Print post
Permalink
In reply to this post by Mauro Casula
Some javascript/style in this post has been disabled (why?)
Hi,

If you have the application in a subdirectory (not webroot) then you may need to set a rewrite base (if using Core) or base url (with Incubator).

Usually it's something like:

$router = new Zend_Controller_RewriteRouter;
/*
 * On my platform, I need to set the RewriteBase for ZF 0.20
 * RewriteBase is assumed to be $_SERVER['PHP_SELF'] after
 * removing the trailing "index.php" string
 */
$rewrite_base = substr($_SERVER['PHP_SELF'], 0, -9);
$router->setRewriteBase($rewrite_base);

//... other controller setup in here

$controller->setRouter($router);

The rest is the same as you have...

If you're using the MVC classes in the incubator directory the process is different (let us know).

Regards,
Pádraic
 


Pádraic Brady
http://blog.quantum-star.com
http://www.patternsforphp.com


----- Original Message ----
From: Mauro Casula <[hidden email]>
To: [hidden email]
Sent: Tuesday, November 14, 2006 1:38:48 PM
Subject: Re: [fw-general] How get Zend_Controller_Dispatcher_Token from index.php


I have upgraded PHP...
Now the application doesnt return errors but only the index action is
showed.

Is this code correct?

    $controller = new Zend_Controller_Front();
    $controller->registerPlugin(new AuthPlugin($db,$session,$post))
               ->setControllerDirectory('../app/controllers');
    $controller->dispatch();









Matthew Weier O wrote:

>
> -- Mauro Casula <[hidden email]> wrote
> (on Tuesday, 14 November 2006, 03:05 AM -0800):
>> Adding
>>     require_once 'Zend/Registry.php';
>> this error disappear.. but i have this:
>>
>> Fatal error: Call to undefined method
>> Zend_Controller_Front::getinstance()
>> in C:\Progetti\Kettler\SITE\kettler\www\index.php on line 68
>>
>> So i have sobstitute in my index.php:
>>    $controller = Zend_Controller_Front::getInstance();
>> with:
>>   $controller = new Zend_Controller_Front();
>
> getInstance() was removed in the incubator component. Basically, we saw
> no reason to force a singleton instance, and having the singleton
> resulted in a testing nightmare.
>
>> but in this case i get this error:
>>
>> Fatal error: Call to undefined method ReflectionClass::newInstanceArgs()
>> in
>> C:\Programmi\php\Zend\incubator\library\Zend\Controller\Dispatcher.php on
>> line 391
>>
>> I think that i'm too much dependent on Core classes...
>>
>> Anyone know what can be the problem?
>
> Yep. Upgrade your PHP version to at least 5.1.4, which is the minimum
> supported version for framework. The method you indicate above,
> ReflectionClass::newInstanceArgs(), is part of PHP's Reflection API, and
> needs to be present for the current version of the dispatcher to work.
> To my knowledge, it's been in PHP since 5.1.2.
>
>
> --
> Matthew Weier O'Phinney
> PHP Developer            | [hidden email]
> Zend - The PHP Company   | http://www.zend.com/
>
>

--
View this message in context: http://www.nabble.com/How-get-Zend_Controller_Dispatcher_Token-from-index.php-tf2621448s16154.html#a7337670
Sent from the Zend Framework mailing list archive at Nabble.com.




Everyone is raving about the all-new Yahoo! Mail beta.
Mauro Casula

Re: How get Zend_Controller_Dispatcher_Token from index.php

Reply Threaded More More options
Print post
Permalink
Hi,
after all, thank you for your help...

I have added your code.. but i receive this error:

Fatal error: Call to undefined method Zend_Controller_RewriteRouter::setRewriteBase() in C:\Progetti\Kettler\SITE\kettler\www\index.php on line 74

I suppose that in the incubator setRewriteBase has been eliminated...
$router->setRewriteBase($rewrite_base);

What i have to do so?


Thank you all.

Mauro.





Pádraic Brady-2 wrote:
Hi,

If you have the application in a subdirectory (not webroot) then you may need to set a rewrite base (if using Core) or base url (with Incubator).

Usually it's something like:

$router = new Zend_Controller_RewriteRouter;
/*
 * On my platform, I need to set the RewriteBase for ZF 0.20
 * RewriteBase is assumed to be $_SERVER['PHP_SELF'] after
 * removing the trailing "index.php" string
 */
$rewrite_base = substr($_SERVER['PHP_SELF'], 0, -9);
$router->setRewriteBase($rewrite_base);

//... other controller setup in here

$controller->setRouter($router);

The rest is the same as you have...

If you're using the MVC classes in the incubator directory the process is different (let us know).

Regards,
Pádraic
 


Pádraic Brady
http://blog.quantum-star.com
http://www.patternsforphp.com


----- Original Message ----
From: Mauro Casula <maurocasula@gmail.com>
To: fw-general@lists.zend.com
Sent: Tuesday, November 14, 2006 1:38:48 PM
Subject: Re: [fw-general] How get Zend_Controller_Dispatcher_Token from index.php


I have upgraded PHP...
Now the application doesnt return errors but only the index action is
showed.

Is this code correct?

    $controller = new Zend_Controller_Front();
    $controller->registerPlugin(new AuthPlugin($db,$session,$post))
               ->setControllerDirectory('../app/controllers');
    $controller->dispatch();









Matthew Weier O wrote:
>
> -- Mauro Casula <maurocasula@gmail.com> wrote
> (on Tuesday, 14 November 2006, 03:05 AM -0800):
>> Adding
>>     require_once 'Zend/Registry.php';
>> this error disappear.. but i have this:
>>
>> Fatal error: Call to undefined method
>> Zend_Controller_Front::getinstance()
>> in C:\Progetti\Kettler\SITE\kettler\www\index.php on line 68
>>
>> So i have sobstitute in my index.php:
>>    $controller = Zend_Controller_Front::getInstance();
>> with:
>>   $controller = new Zend_Controller_Front();
>
> getInstance() was removed in the incubator component. Basically, we saw
> no reason to force a singleton instance, and having the singleton
> resulted in a testing nightmare.
>
>> but in this case i get this error:
>>
>> Fatal error: Call to undefined method ReflectionClass::newInstanceArgs()
>> in
>> C:\Programmi\php\Zend\incubator\library\Zend\Controller\Dispatcher.php on
>> line 391
>>
>> I think that i'm too much dependent on Core classes...
>>
>> Anyone know what can be the problem?
>
> Yep. Upgrade your PHP version to at least 5.1.4, which is the minimum
> supported version for framework. The method you indicate above,
> ReflectionClass::newInstanceArgs(), is part of PHP's Reflection API, and
> needs to be present for the current version of the dispatcher to work.
> To my knowledge, it's been in PHP since 5.1.2.
>
>
> --
> Matthew Weier O'Phinney
> PHP Developer            | matthew@zend.com
> Zend - The PHP Company   | http://www.zend.com/
>
>

--
View this message in context: http://www.nabble.com/How-get-Zend_Controller_Dispatcher_Token-from-index.php-tf2621448s16154.html#a7337670
Sent from the Zend Framework mailing list archive at Nabble.com.








 
____________________________________________________________________________________
Do you Yahoo!?
Everyone is raving about the all-new Yahoo! Mail beta.
http://new.mail.yahoo.com
1 2