Re: [fw-general] Getting error when I try to create first project command line

2010-03-19 Thread Ryan Schmidt

On Mar 19, 2010, at 13:25, Jason Lehman wrote:

> I followed the installation directions but when I run the client I get:
> 
> PHP Fatal error:  Cannot access self:: when no class scope is active in
> /var/backup/zendframeworks/ZendFramework-1.10.2/library/Zend/Tool/Framework/Provider/Signature.php
> on line 355
> 
> 
> I have the path to the library in my php.ini and I see it when I do a php -i
> on the command line.
> 
> I am on CentOS 5.3 and using php 5.1.6 and ZendFramework 1.10.2.

PHP 5.2.4 or later is required.

http://framework.zend.com/manual/en/requirements.introduction.html




Re: [fw-general] Zend_Loader_Autoloader::setZfPath() + application.ini won't ever work

2010-03-19 Thread Jake McGraw
So here is what I ended up doing:

Directory for different versions of ZF
%> mkdir -p /usr/share/php/ZendFramework

Directory for Zend_Loader_*, Zend_Application, Zend_Exception (static
version 1.10.2)
%> mkdir -p /usr/share/php/ZendFrameworkLoader/library/Zend

%> cd /usr/share/php/ZendFramework
%> wget 
http://framework.zend.com/releases/ZendFramework-1.10.2/ZendFramework-1.10.2-minimal.tar.gz
%> tar -xzvf ZendFramework-1.10.2-minimal.tar.gz
%> mv ZendFramework-1.10.2-minimal 1.10.2
%> cd 1.10.2/library/Zend

Copy out Application, Loader classes before removing require_once
%> cp -r Exception.php Application.php Loader*
/usr/share/php/ZendFrameworkLoader/library/Zend

Remove require_once calls from ALL versioned copies of ZF
%> find . -name '*.php' -print0 | xargs -0 sed --regexp-extended
--in-place 's/(require_once)/\/\/ \1/g'

Now in my index.php:
http://gist.github.com/338279

Some takeaways:

1. Won't be able to use pear to keep up to date on ZF, though I knew
this going in.

2. Still can't get application.ini directives to work, though I don't
think I'd want to use application.ini to define my autoloaderZfPath
because then I'd have to segregate a whole bunch of ZF classes.

3. Using this method, the following application.ini directives broke
for me, so I had to replicate the functionality outside of
Zend_Application, in my index.php:

includePaths.library
autoloadernamespaces.My = "My_"

This may be because I'm now replacing the autoloader initialized by
Zend_Application with my own.

4. The section for setZfPath needs to be rewritten to reflect the fact
that you'll need a modified ZF install (without require_once) in order
to use it.

Those issues aside, we're loving the ability to dynamically assign
different ZF versions by environment.

Thanks for all the help!

- Jake


On Fri, Mar 19, 2010 at 2:20 PM, Mike A  wrote:
> On 19 Mar 2010 at 13:22, Matthew Weier O'Phinney wrote:
>> -- Mike A  wrote
>> (on Friday, 19 March 2010, 04:29 PM -):
>> > On 19 Mar 2010 at 10:52, Matthew Weier O'Phinney wrote:
>> >
>> > > -- Jake McGraw  wrote
>> > > (on Thursday, 18 March 2010, 07:02 PM -0400):
>> > > > I'd like to use Zend_Loader_Autoloader::setZfPath() and the
>> > > > autoloaderZfPath application.ini directive to select a ZF version
>> > > > based on Environment, exactly as described here:
>> > > >
>> > > >
>> > > > http://framework.zend.com/manual/en/zend.loader.autoloader.html#zend.loader.autoloader.zf-version
>> > > >
>> > > > What the tutorial fails to cover is how does one introduce
>> > > > Zend/Loader/Autoloader.php into your executing code without knowing
>> > > > the desired ZF path/version before executing Zend_Application? It's
>> > > > a
>> > > > kind of chicken and egg problem. Also, I've noticed that if you
>> > > > don't
>> > > > use the same version of Zend/Loader/Autoloader.php as the one you
>> > > > define in your setZfPath, then you'll get a fatal error (duplicate
>> > > > class) as require_once('Zend/Loader.php') will execute because
>> > > > you're
>> > > > now operating in a different directory. The only way around this
>> > > > issue
>> > > > is to remove every instance of require_once from all ZF classes and
>> > > > rely on Zend_Loader_Autoloader for all file inclusions.
>> > > >
>> > > > So, my question is, how are we supposed to use
>> > > > Zend_Loader_Autoloader::setZfPath() and the autoloaderZf directives?
>> > >
>> > > I'd make the following recommendations:
>> > >
>> > > * Have a tree with just Zend/Exception.php, Zend/Loader.php, and the
>> > >   Zend/Loader/ subtree. Stick that on your include_path. This should
>> > > be
>> > >   from 1.10.0 or later.
>> > >
>> > > * Then, in your index.php, setup autoloading and the ZF version. This
>> > >   will ensure that Zend_Application comes from the version you've
>> > >   selected, and should prevent any issues.
>> > >
>> > > * Optimally, on all versions of ZF, strip the require_once calls, per
>> > >   the performance appendix.
>> >
>> > Is this an argument for Zend shipping ZF with two installs? Part 1 the
>> > core and part 2 the bulk?
>> >
>> > IMHO, philosophically and from a business perspective, it treads on
>> > very dangerous ground for developers to move away from a framework
>> > library by splitting out components - unless that's the shipped
>> > method. Otherwise, what happens with version releases? Where's the
>> > framework integrity?
>>
>> Hold on a moment...
>>
>> The functionality described (autoloading based on ZF version) is
>> basically functionality to support developers who are needing to
>> develop and deploy multiple applications which each target different
>> versions of ZF. My suggestion made above is simply to ensure you don't
>> have conflicts between differing versions of ZF libraries on your
>> include_path (due to needing the ZF library on your include_path in
>> order for the functionality to work in the first place).
>>
>> As for splitting out components, this is actually something we plan to

[fw-general] Re: Trying to add some data to database from a form

2010-03-19 Thread vb

I think you should study in more depth the framework. It is very a powerful
framework, and "unfortunately" very, very flexible framework and therefore
not so easy to start from scratch. 

I think the best way would be to install and get the working demo app from 
http://framework.zend.com/manual/en/learning.quickstart.intro.html
Quickstart .
Than you can start to change it, play with it and learn the framework in
that process.

Looks you are missing some crucial understanding of the framework and MVC
paradigm, and you'll lose very much time fighting it.
-- 
View this message in context: 
http://n4.nabble.com/Trying-to-add-some-data-to-database-from-a-form-tp1599560p1605543.html
Sent from the Zend Framework mailing list archive at Nabble.com.


[fw-general] Re: Trying to add some data to database from a form

2010-03-19 Thread stelios

ok i figured out the problem with your help, thanks for giving me to
understand how it works. i moved my .php files here
application\custom\modules and my images at application\custom\art so i have
to change the image links in my php files can you help me ? first it is
wrong to put my php code under this directories ?

/  logo.png   

what i have to put in logo.png place in order to work ? i put
APPLICATION_PATH."/custom/art/logo.png" but  it doesn't work.
-- 
View this message in context: 
http://n4.nabble.com/Trying-to-add-some-data-to-database-from-a-form-tp1599560p1604592.html
Sent from the Zend Framework mailing list archive at Nabble.com.


[fw-general] Re: Trying to add some data to database from a form

2010-03-19 Thread vb

Hm, I wasn't looking careful enough your code. As I said in my first answer,
index.php is not meant for any output.

Thus, the code from index.php 

 - require('modules/header.php');
 - require('modules/menu.php');

should go to the same place where you have put 

Eshop ...

It doesn't matter if you output directly in the index.php or in its include
files, there is no output before Zend_Session starts. And that is in the
$bootstrap()->run(). 

That is the point where all the bootstrap process has finished.

Output should happen only in your view script (.phtml). 

-- 
View this message in context: 
http://n4.nabble.com/Trying-to-add-some-data-to-database-from-a-form-tp1599560p1599809.html
Sent from the Zend Framework mailing list archive at Nabble.com.


[fw-general] Getting error when I try to create first project command line

2010-03-19 Thread Jason Lehman

I followed the installation directions but when I run the client I get:

PHP Fatal error:  Cannot access self:: when no class scope is active in
/var/backup/zendframeworks/ZendFramework-1.10.2/library/Zend/Tool/Framework/Provider/Signature.php
on line 355


I have the path to the library in my php.ini and I see it when I do a php -i
on the command line.

I am on CentOS 5.3 and using php 5.1.6 and ZendFramework 1.10.2.

Any help would be appreciated.
-- 
View this message in context: 
http://n4.nabble.com/Getting-error-when-I-try-to-create-first-project-command-line-tp1599807p1599807.html
Sent from the Zend Framework mailing list archive at Nabble.com.


Re: [fw-general] Zend_Loader_Autoloader::setZfPath() + application.ini won't ever work

2010-03-19 Thread Mike A
On 19 Mar 2010 at 13:22, Matthew Weier O'Phinney wrote:

> -- Mike A  wrote
> (on Friday, 19 March 2010, 04:29 PM -):
> > On 19 Mar 2010 at 10:52, Matthew Weier O'Phinney wrote:
> > 
> > > -- Jake McGraw  wrote
> > > (on Thursday, 18 March 2010, 07:02 PM -0400):
> > > > I'd like to use Zend_Loader_Autoloader::setZfPath() and the
> > > > autoloaderZfPath application.ini directive to select a ZF version
> > > > based on Environment, exactly as described here:
> > > > 
> > > > http://framework.zend.com/manual/en/zend.loader.autoloader.html#zend.loader.autoloader.zf-version
> > > > 
> > > > What the tutorial fails to cover is how does one introduce
> > > > Zend/Loader/Autoloader.php into your executing code without knowing
> > > > the desired ZF path/version before executing Zend_Application? It's a
> > > > kind of chicken and egg problem. Also, I've noticed that if you don't
> > > > use the same version of Zend/Loader/Autoloader.php as the one you
> > > > define in your setZfPath, then you'll get a fatal error (duplicate
> > > > class) as require_once('Zend/Loader.php') will execute because you're
> > > > now operating in a different directory. The only way around this issue
> > > > is to remove every instance of require_once from all ZF classes and
> > > > rely on Zend_Loader_Autoloader for all file inclusions.
> > > > 
> > > > So, my question is, how are we supposed to use
> > > > Zend_Loader_Autoloader::setZfPath() and the autoloaderZf directives?
> > > 
> > > I'd make the following recommendations:
> > > 
> > > * Have a tree with just Zend/Exception.php, Zend/Loader.php, and the
> > >   Zend/Loader/ subtree. Stick that on your include_path. This should be
> > >   from 1.10.0 or later.
> > > 
> > > * Then, in your index.php, setup autoloading and the ZF version. This
> > >   will ensure that Zend_Application comes from the version you've
> > >   selected, and should prevent any issues.
> > > 
> > > * Optimally, on all versions of ZF, strip the require_once calls, per
> > >   the performance appendix.
> > 
> > Is this an argument for Zend shipping ZF with two installs? Part 1 the
> > core and part 2 the bulk?
> > 
> > IMHO, philosophically and from a business perspective, it treads on
> > very dangerous ground for developers to move away from a framework
> > library by splitting out components - unless that's the shipped
> > method. Otherwise, what happens with version releases? Where's the
> > framework integrity?
> 
> Hold on a moment...
> 
> The functionality described (autoloading based on ZF version) is
> basically functionality to support developers who are needing to
> develop and deploy multiple applications which each target different
> versions of ZF. My suggestion made above is simply to ensure you don't
> have conflicts between differing versions of ZF libraries on your
> include_path (due to needing the ZF library on your include_path in
> order for the functionality to work in the first place).
> 
> As for splitting out components, this is actually something we plan to
> do for ZF2. All components would be versioned the same, but you'd be
> able to install a component and its dependencies anatomically. This
> helps answer the "use-at-will" nature of ZF much better, as it allows
> developers to choose the components they're using and only install
> those, instead of the entire framework. That said, since the framework
> would be versioned as a whole, if you install Zend\Filter from 2.0.1, it
> would install only dependencies from 2.0.1 -- framework integrity would
> be kept. (BTW, we'd be using Pyrus as the installer in this situation.)

Thanks once again Matthew.

As for the autoloading based on ZF version I wholeheartedly understand that 
whilst a 
developer would wish to "muck around", a release version should avoid it. That 
is not what 
the manual implies though - it refers to "fixing" a version in context with the 
mucking around 
bit.

For the vendor to come out and mention splitting out components (I presume you 
mean 
components families) as part of the philosophy is wonderful news. Such managed 
philosophy 
is streaks ahead of the porridge-cum-spaghetti found in other products like 
those beginning 
with C or D - that's not to decry either porridge or spaghetti as foods ;)

Does the step towards Pyrus (http://pear.php.net/manual/en/pyrus.php) suggest a 
wholesale 
use of an XML config file with which non-Zend products (modules) can be 
registered and 
plugged? If so, are there any references/blog posts on the subject and what's 
going to 
happen? They would be useful.

Cheers...

Mike A.



[fw-general] Re: Trying to add some data to database from a form

2010-03-19 Thread stelios

1- Well, check your modules\header.php, line 3, as the message states.
Someone is outputting on line 3 or before. Maybe an include file.

2- Check that there are no spaces/anything before "" in php files. Spaces after can/will cause
outputting.

4- Check if any file has UTF BOM chars at the beginning. Those are invisible
so I'm using Notepad++ for that. 


1 my header.php code is in above post, the strange is that if i remove
everything and i leave the 2 includes,it works... so i thing the error has
something to do with the echo

2 there are no spaces

3 i deleted them all

4 none of them
-- 
View this message in context: 
http://n4.nabble.com/Trying-to-add-some-data-to-database-from-a-form-tp1599560p1599798.html
Sent from the Zend Framework mailing list archive at Nabble.com.


[fw-general] Re: Trying to add some data to database from a form

2010-03-19 Thread vb

- Well, check your modules\header.php, line 3, as the message states. Someone
is outputting on line 3 or before. Maybe an include file.

- Check that there are no spaces/anything before "" in php files. Spaces after can/will cause
outputting.

- Check if any file has UTF BOM chars at the beginning. Those are invisible
so I'm using Notepad++ for that.

-- 
View this message in context: 
http://n4.nabble.com/Trying-to-add-some-data-to-database-from-a-form-tp1599560p1599783.html
Sent from the Zend Framework mailing list archive at Nabble.com.


[fw-general] Re: Trying to add some data to database from a form

2010-03-19 Thread stelios

ok thanks, i managed to figure it out a while after i first posted and i
corrected. but now i have another issue...

Fatal error: Uncaught exception 'Zend_Controller_Response_Exception' with
message 'Cannot send headers; headers already sent in
C:\xampp\htdocs\eshop\public\modules\header.php, line 3. blah blah.

and my header.php is this

';
// plaisio

echo '';

echo ''; 

echo ' /  /art/logo.png   ';

echo '';

require ('thetime.php');

echo '';

require('modules/search.php');

?>
-- 
View this message in context: 
http://n4.nabble.com/Trying-to-add-some-data-to-database-from-a-form-tp1599560p1599755.html
Sent from the Zend Framework mailing list archive at Nabble.com.


[fw-general] Re: Trying to add some data to database from a form

2010-03-19 Thread vb

In ZF, index.php is not meant for outputting any characters and definitely
not the HTML code. It is the entry point to you app. It makes first
initializations, like include_path.

The HTML code (Eshop ... ) should go into your process.phtml
(or in your .phtml layout script, if you're using it, e.g. common.phtml). 


If for some strange reason you really want that code there, you should start
session manually.


Eshop 


Re: [fw-general] Zend_Loader_Autoloader::setZfPath() + application.ini won't ever work

2010-03-19 Thread Matthew Weier O'Phinney
-- Mike A  wrote
(on Friday, 19 March 2010, 04:29 PM -):
> On 19 Mar 2010 at 10:52, Matthew Weier O'Phinney wrote:
> 
> > -- Jake McGraw  wrote
> > (on Thursday, 18 March 2010, 07:02 PM -0400):
> > > I'd like to use Zend_Loader_Autoloader::setZfPath() and the
> > > autoloaderZfPath application.ini directive to select a ZF version
> > > based on Environment, exactly as described here:
> > > 
> > > http://framework.zend.com/manual/en/zend.loader.autoloader.html#zend.loader.autoloader.zf-version
> > > 
> > > What the tutorial fails to cover is how does one introduce
> > > Zend/Loader/Autoloader.php into your executing code without knowing
> > > the desired ZF path/version before executing Zend_Application? It's a
> > > kind of chicken and egg problem. Also, I've noticed that if you don't
> > > use the same version of Zend/Loader/Autoloader.php as the one you
> > > define in your setZfPath, then you'll get a fatal error (duplicate
> > > class) as require_once('Zend/Loader.php') will execute because you're
> > > now operating in a different directory. The only way around this issue
> > > is to remove every instance of require_once from all ZF classes and
> > > rely on Zend_Loader_Autoloader for all file inclusions.
> > > 
> > > So, my question is, how are we supposed to use
> > > Zend_Loader_Autoloader::setZfPath() and the autoloaderZf directives?
> > 
> > I'd make the following recommendations:
> > 
> > * Have a tree with just Zend/Exception.php, Zend/Loader.php, and the
> >   Zend/Loader/ subtree. Stick that on your include_path. This should be
> >   from 1.10.0 or later.
> > 
> > * Then, in your index.php, setup autoloading and the ZF version. This
> >   will ensure that Zend_Application comes from the version you've
> >   selected, and should prevent any issues.
> > 
> > * Optimally, on all versions of ZF, strip the require_once calls, per
> >   the performance appendix.
> 
> Is this an argument for Zend shipping ZF with two installs? Part 1 the
> core and part 2 the bulk?
> 
> IMHO, philosophically and from a business perspective, it treads on
> very dangerous ground for developers to move away from a framework
> library by splitting out components - unless that's the shipped
> method. Otherwise, what happens with version releases? Where's the
> framework integrity?

Hold on a moment...

The functionality described (autoloading based on ZF version) is
basically functionality to support developers who are needing to
develop and deploy multiple applications which each target different
versions of ZF. My suggestion made above is simply to ensure you don't
have conflicts between differing versions of ZF libraries on your
include_path (due to needing the ZF library on your include_path in
order for the functionality to work in the first place).

As for splitting out components, this is actually something we plan to
do for ZF2. All components would be versioned the same, but you'd be
able to install a component and its dependencies anatomically. This
helps answer the "use-at-will" nature of ZF much better, as it allows
developers to choose the components they're using and only install
those, instead of the entire framework. That said, since the framework
would be versioned as a whole, if you install Zend\Filter from 2.0.1, it
would install only dependencies from 2.0.1 -- framework integrity would
be kept. (BTW, we'd be using Pyrus as the installer in this situation.)

-- 
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


Re: [fw-general] Zend_Loader_Autoloader::setZfPath() + application.ini won't ever work

2010-03-19 Thread Mike A
On 19 Mar 2010 at 10:52, Matthew Weier O'Phinney wrote:

> -- Jake McGraw  wrote
> (on Thursday, 18 March 2010, 07:02 PM -0400):
> > I'd like to use Zend_Loader_Autoloader::setZfPath() and the
> > autoloaderZfPath application.ini directive to select a ZF version
> > based on Environment, exactly as described here:
> > 
> > http://framework.zend.com/manual/en/zend.loader.autoloader.html#zend.loader.autoloader.zf-version
> > 
> > What the tutorial fails to cover is how does one introduce
> > Zend/Loader/Autoloader.php into your executing code without knowing
> > the desired ZF path/version before executing Zend_Application? It's a
> > kind of chicken and egg problem. Also, I've noticed that if you don't
> > use the same version of Zend/Loader/Autoloader.php as the one you
> > define in your setZfPath, then you'll get a fatal error (duplicate
> > class) as require_once('Zend/Loader.php') will execute because you're
> > now operating in a different directory. The only way around this issue
> > is to remove every instance of require_once from all ZF classes and
> > rely on Zend_Loader_Autoloader for all file inclusions.
> > 
> > So, my question is, how are we supposed to use
> > Zend_Loader_Autoloader::setZfPath() and the autoloaderZf directives?
> 
> I'd make the following recommendations:
> 
> * Have a tree with just Zend/Exception.php, Zend/Loader.php, and the
>   Zend/Loader/ subtree. Stick that on your include_path. This should be
>   from 1.10.0 or later.
> 
> * Then, in your index.php, setup autoloading and the ZF version. This
>   will ensure that Zend_Application comes from the version you've
>   selected, and should prevent any issues.
> 
> * Optimally, on all versions of ZF, strip the require_once calls, per
>   the performance appendix.

Is this an argument for Zend shipping ZF with two installs? Part 1 the core and 
part 2 the 
bulk?

IMHO, philosophically and from a business perspective, it treads on very 
dangerous ground 
for developers to move away from a framework library by splitting out 
components - unless 
that's the shipped method. Otherwise, what happens with version releases? 
Where's the 
framework integrity?

(o)



[fw-general] Re: Zend Router with Hostname and other routes

2010-03-19 Thread kilowatt303

Well i have solved it myself, here is the solution:




Zend_Controller_Router_Route_Hostname
:username.avidimages.net


Zend_Controller_Router_Route_Module
On

default



pages/:url

default
pages
view






-- 
View this message in context: 
http://n4.nabble.com/Zend-Router-with-Hostname-and-other-routes-tp1599492p1599597.html
Sent from the Zend Framework mailing list archive at Nabble.com.


Re: [fw-general] Zend_Navigation and 'onclick'

2010-03-19 Thread Hector Virgen
I'm not sure if you can add custom attributes to the navigation, but why not
use external Javascript for this instead of inline? In jQuery it would be
simple:

jQuery(function($)
{
$('ul.navigation a[href="#"]').click(function(event)
{
event.preventDefault();
});
});

--
Hector


On Fri, Mar 19, 2010 at 1:32 AM, Rocco Bruyn  wrote:

>  Hi all,
>
>
>
> I’m working on a project which (surprisingly) has pages and a navigation
> menu.
>
> The ‘elbows’ in the menu are not clickable. They just expand the underlying
> sub-pages.
>
> This works fine by creating a Zend_Navigation_Page_Uri with an uri ‘#’.
>
> But the browser still responds to the click which I want to prevent by
> adding an attribute onclick=”return false”.
>
> I can’t seem to figure out how to do this. Most simple case would be:
>
>
>
> $nav = new Zend_Navigation(array(
>
>   array(
>
> 'label'   => 'Folder',
>
> 'uri' => '#',
>
> 'onclick' => 'return false'
>
>   )
>
> ));
>
>
>
> $helper = new Zend_View_Helper_Navigation_Menu();
>
> $helper->setView(new Zend_View());
>
>
>
> echo $helper->render($nav);
>
>
>
> But doesn’t work as expected.
>
> Can anyone shed a light on this?
>
>
>
> Regards,
>
> Rocco
>
>
>
>
>
>
>


[fw-general] RE: Graphs using Zend Framework

2010-03-19 Thread kilowatt303

Here is how i set up OpenFlash charts
(http://teethgrinder.co.uk/open-flash-chart/)
Controller action:

public function statsAction(){
$this->_helper->viewRenderer->setNoRender(true);
$this->_helper->layout->disableLayout();
$transactions = new Orders();
$data = $transactions->fetchPreviousMonth();
require_once('OFC/OFC_Chart.php');

$title = new OFC_Elements_Title('Orders');

//$line_dot = new OFC_Charts_Line();
$line_dot = new OFC_Charts_Line_Hollow();
$line_dot->set_values($data->toArray());

$chart = new OFC_Chart();
$chart->set_bg_colour('ff');
$chart->set_title( $title );
$chart->add_element( $line_dot );

echo $chart->toPrettyString();
}

View:

headScript()->appendFile('/js/swfobject.js');
$this->headScript()->appendScript('
swfobject.embedSWF(
"/swf/open-flash-chart.swf", "chart",
"940", "400", "9.0.0", "expressInstall.swf",
{"data-file":"/index/stats"} );');
?>




Hope it helps!
-- 
View this message in context: 
http://n4.nabble.com/Graphs-using-Zend-Framework-tp1593094p1599528.html
Sent from the Zend Framework mailing list archive at Nabble.com.


Re: [fw-general] Using an external database for user credential

2010-03-19 Thread Hector Virgen
The only thing that is "automatic" regarding the DB is Zend_Db_Table and its
default adapter. You can specify the default by using this confing option:

resources.multidb.db2.default = true

For everything else, you'll need to inject the db instance into your models
(for example, by injecting into a data mapper) or access it statically with:

$db =
Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('multidb')->getDb('db2');

Injection is preferred because it makes unit testing easier.

--
Hector


On Fri, Mar 19, 2010 at 2:15 AM, Sergio Rinaudo wrote:

>  Thank you very much for your advices Hector.
> I have one more question, is anything changing on models management using
> multidb?
> How do a model know which database resource must use?
> Thanks
>
>
> Sergio
>
>
>
>
> --
> From: djvir...@gmail.com
> Date: Tue, 16 Mar 2010 09:23:26 -0700
> Subject: Re: [fw-general] Using an external database for user credential
> To: kaiohken1...@hotmail.com
> CC: fw-general@lists.zend.com
>
>
> Take a look at the "multidb" resource:
>
>
> http://framework.zend.com/manual/en/zend.application.available-resources.html
>
>
> You
> could then inject your authentication adapter with the correct db:
>
> // in controller
> $db =
> $this->getInvokeArg('bootstrap')->getResource('multidb')->getDb('db2')
> $authAdapter = new Zend_Auth_Adapter_DbTable(
> $db,
> $tabUsers,
> 'username',
> 'password'
> );
>
> This would eliminate the need for you to construct your own db adapter from
> the config.
>
> Also, you'll want to use boolean false for isDefaultTableAdapter -- when
> it's set to true, that db instance will be used for all Zend_Db_Table
> instances by default.
>
> --
> Hector
>
>
> On Tue, Mar 16, 2010 at 2:34 AM, Sergio Rinaudo 
> wrote:
>
>  Hello,
> I am in a situation where I have to use an external database to check
> credential for user.
> Is there any right way to do this in the application ini?
>
> I thoughts something like
>
>   resources.db2.adapter = // external db adapter
>   resources.db2.params.host = // external db host
>   resources.db2.params.username = // external db user
>   resources.db2.params.password = // external db pass
>   resources.db2.params.dbname = // external db name
>   resources.db2.isDefaultTableAdapter =  // what am I supposed to put here?
>   resources.db2.params.charset = UTF8
>   resources.db2.profiler.enabled = true
>
> Save it in the registry whitin bootstrap
>
> $db2 = // some code
> $registry->db2 = $db2;
>
> Use $db2 to check credential in auth controller
>
> $db2 = Zend_Registry::get('db2');
> $authAdapter = new Zend_Auth_Adapter_DbTable(
>   $db2,
>   $tabUsers,
>   'username',
>   'password',
>   "SHA1(CONCAT('".$salt."',?)) AND status_id = '".$status_id."' "
>   );
>
>
> Is that a correct way to do or there is something better?
> Thanks in advance for all your advices.
>
>
>
> Sergio
>
>
>
>
> --
> Lo spazio su Hotmail aumente con le tue esigenze... Vai oltre i 
> 5GB
>
>
>
> --
> Lo spazio su Hotmail aumente con le tue esigenze... Vai oltre i 
> 5GB
>


[fw-general] Zend Router with Hostname and other routes

2010-03-19 Thread kilowatt303

Hello all,
Its been years since i was stuck enough with anything to ask for help, but
this is driving me nuts!
My router config:




Zend_Controller_Router_Route_Hostname
:username.example.com


Zend_Controller_Router_Route_Module
On

default



Zend_Controller_Router_Route_Chain
user, defaultmodule


pages/:url

default
pages
view




Bootstrap:

protected function _initRoutes() {
$this->bootstrap('frontController');
$front = $this->frontController;
$router = $front->getRouter();
$config = new
Zend_Config_Xml(APPLICATION_PATH.'/configs/routes.xml');
$router->addConfig($config);
}

When visiting anything other than /pages everything works fine, but when i
go to say demo.example.com/pages/whatever, the router does not register the
default route so the application does not get the "username" parameter.
I have tried chaining pages to default route every way possible, tried
moving the pages around in the config it breaks as well.
Your help would be much appreciated!
-- 
View this message in context: 
http://n4.nabble.com/Zend-Router-with-Hostname-and-other-routes-tp1599492p1599492.html
Sent from the Zend Framework mailing list archive at Nabble.com.


Re: [fw-general] Zend_Loader_Autoloader::setZfPath() + application.ini won't ever work

2010-03-19 Thread Matthew Weier O'Phinney
-- Jake McGraw  wrote
(on Thursday, 18 March 2010, 07:02 PM -0400):
> I'd like to use Zend_Loader_Autoloader::setZfPath() and the
> autoloaderZfPath application.ini directive to select a ZF version
> based on Environment, exactly as described here:
> 
> http://framework.zend.com/manual/en/zend.loader.autoloader.html#zend.loader.autoloader.zf-version
> 
> What the tutorial fails to cover is how does one introduce
> Zend/Loader/Autoloader.php into your executing code without knowing
> the desired ZF path/version before executing Zend_Application? It's a
> kind of chicken and egg problem. Also, I've noticed that if you don't
> use the same version of Zend/Loader/Autoloader.php as the one you
> define in your setZfPath, then you'll get a fatal error (duplicate
> class) as require_once('Zend/Loader.php') will execute because you're
> now operating in a different directory. The only way around this issue
> is to remove every instance of require_once from all ZF classes and
> rely on Zend_Loader_Autoloader for all file inclusions.
> 
> So, my question is, how are we supposed to use
> Zend_Loader_Autoloader::setZfPath() and the autoloaderZf directives?

I'd make the following recommendations:

* Have a tree with just Zend/Exception.php, Zend/Loader.php, and the
  Zend/Loader/ subtree. Stick that on your include_path. This should be
  from 1.10.0 or later.

* Then, in your index.php, setup autoloading and the ZF version. This
  will ensure that Zend_Application comes from the version you've
  selected, and should prevent any issues.

* Optimally, on all versions of ZF, strip the require_once calls, per
  the performance appendix.

-- 
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


Re: [fw-general] HTTP response code when not logged in

2010-03-19 Thread Matthew Weier O'Phinney
-- Marian Meres  wrote
(on Friday, 19 March 2010, 08:43 AM +0100):
> what kind of HTTP response codes would you suggest using when
> accessing a page which requires user to be logged in and there is no
> current identity present?
> 
> Initially I thought about "401 Unauthorized", but the definition says:
> "The response MUST include a WWW-Authenticate header field containing
> a challenge applicable to the requested resource" where I'm not sure I
> know what that means...

I've used a 401 error code quite a number of times, and consider it
perfectly valid. While the spec indicates the WWW-Authenticate header is
required, I have yet to see a browser that acts on it, nor can I think
of any apps off hand that actually use it; I certainly haven't seen any
negative side-effects from not supplying it.

So, based on that anecdotal evidence... I'd go ahead and use it.

> I also thought about "403 Forbidden", but again from the definition:
> "Authorization will not help and the request SHOULD NOT be repeated"
> does not look like a good choice.
> 
> Or forget it and stick with good old "200 OK"?

-- 
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


[fw-general] Model class is not found in zend framework project (quickstart)

2010-03-19 Thread Dumindu

The things I did is
   1. zf create project demo1 in command prompt
   2. add the lines to application.ini
  * appnamespace = "Application"
  * resources.layout.layoutPath = APPLICATION_PATH
"/layouts/scripts"
   3. add a layout with header and footer using partial() (They are
perfectly worked)
   4.create Data.php in application/models directory and add this simple
class

  http://n4.nabble.com/Model-class-is-not-found-in-zend-framework-project-quickstart-tp1599378p1599378.html
Sent from the Zend Framework mailing list archive at Nabble.com.


Re: [fw-general] Zend_Loader_Autoloader::setZfPath() + application.ini won't ever work

2010-03-19 Thread scs
Hi,
I had exactly the same problem.

*ZendFramework dir structure (the same of the example on zf manual)
-project
--ZendFramework
1.10.2-minimal
1.9.6-minimal


*project/public/index.php
//PROJECT_ROOT_DIR is defined above

set_include_path(implode(PATH_SEPARATOR, array(
'/usr/share/php', //zend library is here /usr/share/php/Zend
realpath(APPLICATION_PATH . '/../library'),
)));

/** Zend_Application */
require_once 'Zend/Application.php';

// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap()
->run();

*project/application/configs/application.ini
autoloaderZfPath = PROJECT_ROOT_DIR "/ZendFramework/"
autoloaderZfVersion = "1.9.6"


Now, I have to add '/usr/share/php' for Zend Framework library so that the line
require_once 'Zend/Application.php';
will not give not found error.

And when I add the zfpath lines in application ini, then I get "cannot
redeclare ... " errors.

thanks,
scs


On Fri, Mar 19, 2010 at 4:18 PM, Jake McGraw  wrote:
> On Fri, Mar 19, 2010 at 2:17 AM, Mike A  wrote:
>> On 18 Mar 2010 at 19:02, Jake McGraw wrote:
>>> I'd like to use Zend_Loader_Autoloader::setZfPath() and the
>>> autoloaderZfPath application.ini directive to select a ZF version
>>> based on Environment, exactly as described here:
>>>
>>>
>>> http://framework.zend.com/manual/en/zend.loader.autoloader.html#zend.loader.autoloader.zf-version
>>>
>>> What the tutorial fails to cover is how does one introduce
>>> Zend/Loader/Autoloader.php into your executing code without knowing
>>> the desired ZF path/version before executing Zend_Application? It's a
>>> kind of chicken and egg problem. Also, I've noticed that if you don't
>>> use the same version of Zend/Loader/Autoloader.php as the one you
>>> define in your setZfPath, then you'll get a fatal error (duplicate
>>> class) as require_once('Zend/Loader.php') will execute because you're
>>> now operating in a different directory. The only way around this issue
>>> is to remove every instance of require_once from all ZF classes and
>>> rely on Zend_Loader_Autoloader for all file inclusions.
>>>
>>> So, my question is, how are we supposed to use
>>> Zend_Loader_Autoloader::setZfPath() and the autoloaderZf directives?
>> As it happens I have just written about this issue in a
>> book chapter under authorship. Not perfect, but try...
>> $libraries="/../libraries/";
>> $zf_path="ZF";
>> $zf_ver="1.10.2";
>
> Ok, but your use of $zf_path and $zf_ver makes the whole
> autoloaderZfPath, autoloaderZfVersion application.ini directives moot,
> correct? What I don't understand is, how does one use
> Zend_Loader_Autoloader::setZfPath(), without first loading some
> components of the Zend Framework?
>
> What I've encountered is that, as soon as you include/instantiate
> Zend_Loader_Autoloader, you've sullied the namespace, require_once
> won't look in the same directory as the original version of ZF that
> you used to include the autoloader, therefore, any duplicate
> require_once's will cause duplicate class errors.
>
> So, my question still stands, how does one use
> Zend_Loader_Autoloader::setZfPath(), where the ZF path will be
> different from the one used to include the autoloader?
>
>> // Ensure 'libraries/' folder is on include_path
>> set_include_path(implode(PATH_SEPARATOR, array(
>>  realpath(APPLICATION_PATH .
>>  $libraries.$zf_path.'/'.$zf_ver.'/library/'),
>>  get_include_path(), )));
>> require_once 'Zend/Application.php';
>> $application = new Zend_Application(
>>  APPLICATION_ENV,
>>  APPLICATION_PATH . '/config/config.ini'
>>  );
>> $autoloader = Zend_Loader_Autoloader::getInstance();
>> $path=realpath(APPLICATION_PATH . $libraries.$zf_path);
>> $autoloader->setZfPath($path, $zf_ver);
>> My folder structure matches the one in the example except
>> that Zend framework ("$zf_path") sits one level below my
>> libraries because I have personalised libraries I also
>> want to access.
>> It's messy, with more lines of code than necessary in a
>> perfect world - read "perfect framework" ;)  Also,
>> depending on the need to transport across OSs, it may be
>> desirable to use the PATH_SEPARATOR constant in place of
>> "/". It does, though, enable a single change of $zf_ver to
>> attach the appropriate ZF version.
>> HTH a little...
>> Mike A.
>>
>


Re: [fw-general] Zend_Loader_Autoloader::setZfPath() + application.ini won't ever work

2010-03-19 Thread Jake McGraw
On Fri, Mar 19, 2010 at 2:17 AM, Mike A  wrote:
> On 18 Mar 2010 at 19:02, Jake McGraw wrote:
>> I'd like to use Zend_Loader_Autoloader::setZfPath() and the
>> autoloaderZfPath application.ini directive to select a ZF version
>> based on Environment, exactly as described here:
>>
>>
>> http://framework.zend.com/manual/en/zend.loader.autoloader.html#zend.loader.autoloader.zf-version
>>
>> What the tutorial fails to cover is how does one introduce
>> Zend/Loader/Autoloader.php into your executing code without knowing
>> the desired ZF path/version before executing Zend_Application? It's a
>> kind of chicken and egg problem. Also, I've noticed that if you don't
>> use the same version of Zend/Loader/Autoloader.php as the one you
>> define in your setZfPath, then you'll get a fatal error (duplicate
>> class) as require_once('Zend/Loader.php') will execute because you're
>> now operating in a different directory. The only way around this issue
>> is to remove every instance of require_once from all ZF classes and
>> rely on Zend_Loader_Autoloader for all file inclusions.
>>
>> So, my question is, how are we supposed to use
>> Zend_Loader_Autoloader::setZfPath() and the autoloaderZf directives?
> As it happens I have just written about this issue in a
> book chapter under authorship. Not perfect, but try...
> $libraries="/../libraries/";
> $zf_path="ZF";
> $zf_ver="1.10.2";

Ok, but your use of $zf_path and $zf_ver makes the whole
autoloaderZfPath, autoloaderZfVersion application.ini directives moot,
correct? What I don't understand is, how does one use
Zend_Loader_Autoloader::setZfPath(), without first loading some
components of the Zend Framework?

What I've encountered is that, as soon as you include/instantiate
Zend_Loader_Autoloader, you've sullied the namespace, require_once
won't look in the same directory as the original version of ZF that
you used to include the autoloader, therefore, any duplicate
require_once's will cause duplicate class errors.

So, my question still stands, how does one use
Zend_Loader_Autoloader::setZfPath(), where the ZF path will be
different from the one used to include the autoloader?

> // Ensure 'libraries/' folder is on include_path
> set_include_path(implode(PATH_SEPARATOR, array(
>  realpath(APPLICATION_PATH .
>  $libraries.$zf_path.'/'.$zf_ver.'/library/'),
>  get_include_path(), )));
> require_once 'Zend/Application.php';
> $application = new Zend_Application(
>  APPLICATION_ENV,
>  APPLICATION_PATH . '/config/config.ini'
>  );
> $autoloader = Zend_Loader_Autoloader::getInstance();
> $path=realpath(APPLICATION_PATH . $libraries.$zf_path);
> $autoloader->setZfPath($path, $zf_ver);
> My folder structure matches the one in the example except
> that Zend framework ("$zf_path") sits one level below my
> libraries because I have personalised libraries I also
> want to access.
> It's messy, with more lines of code than necessary in a
> perfect world - read "perfect framework" ;)  Also,
> depending on the need to transport across OSs, it may be
> desirable to use the PATH_SEPARATOR constant in place of
> "/". It does, though, enable a single change of $zf_ver to
> attach the appropriate ZF version.
> HTH a little...
> Mike A.
>


Re: [fw-general] Would anyone want Zend_VersionControl_Subversion?

2010-03-19 Thread Саша Стаменковић
Nice to have.

Regards,
Saša Stamenković


On Fri, Mar 19, 2010 at 12:58 PM, Shaun Farrell  wrote:

> Steven,
> I would like to see this too!
> I like Zend_VersionControl_*
>
> Look forward to see it something.
>
> Shaun J. Farrell
> Washington, DC
> (202) 713-5241
> www.farrelley.com
>
>
>
> On Thu, Mar 18, 2010 at 6:00 PM, Danny Fröberg <
> danny.frob...@foreststar.net> wrote:
>
>>  Steven,
>>
>> Yes would love to have it, use case could be for having self updating apps
>> deployed.
>>
>>
>>
>> Regards
>>
>> Danny
>>
>>
>>
>> *From:* Steven Brown [mailto:ste...@yewchube.com]
>> *Sent:* den 18 mars 2010 22:59
>> *To:* fw-general@lists.zend.com
>> *Subject:* [fw-general] Would anyone want Zend_VersionControl_Subversion?
>>
>>
>>
>> For fun, I began experimenting with putting together a PHP implementation
>> of a Subversion client that uses the svn protocol and thought it might be a
>> useful addition to ZF.
>>
>>
>>
>> Bill Karwin pointed out that a PECL extension already exists to provide
>> this functionality, though the documentation is filled with warnings about
>> it being experimental.
>>
>>
>>
>> I suggest that it is possible in some hosting environments that developers
>> won’t have the PECL extension installed and may not be able to install it.
>>
>>
>>
>> Some uses for such a module include:
>>
>>
>>
>> 1.   Deployment – code can be installed or updated using PHP code
>>
>> 2.   Repository browsing – for tools such as bug/issue trackers
>>
>> 3.   Committing – for example if files can be changed in an admin
>> area, the changes can be committed to the repository
>>
>>
>>
>> I think it should be possible to provide similar functionality for Git,
>> Mercurial, and other version control systems.
>>
>>
>>
>> I have already started developing an adapter that uses the svn protocol,
>> but others could be created that use SSH or LDAP/HTTP access, or the PECL
>> extension.
>>
>>
>>
>> Would Zend_VersionControl_Subversion be useful or is it just a waste of
>> time?
>>
>>
>>
>> Cheers,
>>
>> Steven
>>
>
>


Re: [fw-general] Would anyone want Zend_VersionControl_Subversion?

2010-03-19 Thread Shaun Farrell
Steven,
I would like to see this too!
I like Zend_VersionControl_*

Look forward to see it something.

Shaun J. Farrell
Washington, DC
(202) 713-5241
www.farrelley.com


On Thu, Mar 18, 2010 at 6:00 PM, Danny Fröberg  wrote:

>  Steven,
>
> Yes would love to have it, use case could be for having self updating apps
> deployed.
>
>
>
> Regards
>
> Danny
>
>
>
> *From:* Steven Brown [mailto:ste...@yewchube.com]
> *Sent:* den 18 mars 2010 22:59
> *To:* fw-general@lists.zend.com
> *Subject:* [fw-general] Would anyone want Zend_VersionControl_Subversion?
>
>
>
> For fun, I began experimenting with putting together a PHP implementation
> of a Subversion client that uses the svn protocol and thought it might be a
> useful addition to ZF.
>
>
>
> Bill Karwin pointed out that a PECL extension already exists to provide
> this functionality, though the documentation is filled with warnings about
> it being experimental.
>
>
>
> I suggest that it is possible in some hosting environments that developers
> won’t have the PECL extension installed and may not be able to install it.
>
>
>
> Some uses for such a module include:
>
>
>
> 1.   Deployment – code can be installed or updated using PHP code
>
> 2.   Repository browsing – for tools such as bug/issue trackers
>
> 3.   Committing – for example if files can be changed in an admin
> area, the changes can be committed to the repository
>
>
>
> I think it should be possible to provide similar functionality for Git,
> Mercurial, and other version control systems.
>
>
>
> I have already started developing an adapter that uses the svn protocol,
> but others could be created that use SSH or LDAP/HTTP access, or the PECL
> extension.
>
>
>
> Would Zend_VersionControl_Subversion be useful or is it just a waste of
> time?
>
>
>
> Cheers,
>
> Steven
>


RE: [fw-general] Using an external database for user credential

2010-03-19 Thread Sergio Rinaudo

Thank you very much for your advices Hector.
I have one more question, is anything changing on models management using 
multidb?
How do a model know which database resource must use?
Thanks


Sergio 




From: djvir...@gmail.com
Date: Tue, 16 Mar 2010 09:23:26 -0700
Subject: Re: [fw-general] Using an external database for user credential
To: kaiohken1...@hotmail.com
CC: fw-general@lists.zend.com

Take a look at the "multidb" resource:
http://framework.zend.com/manual/en/zend.application.available-resources.html


You could then inject your authentication adapter with the correct db:
// in controller

$db = 
$this->getInvokeArg('bootstrap')->getResource('multidb')->getDb('db2')$authAdapter
 = new Zend_Auth_Adapter_DbTable(

$db,$tabUsers,'username',

'password');


This would eliminate the need for you to construct your own db adapter from the 
config.
Also, you'll want to use boolean false for isDefaultTableAdapter -- when it's 
set to true, that db instance will be used for all Zend_Db_Table instances by 
default.


--
Hector



On Tue, Mar 16, 2010 at 2:34 AM, Sergio Rinaudo  
wrote:







Hello, 
I am in a situation where I have to use an external database to check 
credential for user.
Is there any right way to do this in the application ini?

I thoughts something like

  resources.db2.adapter = // external db adapter


  resources.db2.params.host = // external db host
  resources.db2.params.username = // external db user
  resources.db2.params.password = // external db pass
  resources.db2.params.dbname = // external db name


  resources.db2.isDefaultTableAdapter =  // what am I supposed to put here?
  resources.db2.params.charset = UTF8
  resources.db2.profiler.enabled = true

Save it in the registry whitin bootstrap

$db2 = // some code


$registry->db2 = $db2;

Use $db2 to check credential in auth controller

$db2 = Zend_Registry::get('db2');
$authAdapter = new Zend_Auth_Adapter_DbTable(
  $db2,
  $tabUsers,


  'username',
  'password',
  "SHA1(CONCAT('".$salt."',?)) AND status_id = '".$status_id."' "
  );


Is that a correct way to do or there is something better?


Thanks in advance for all your advices.



Sergio 




  
Lo spazio su Hotmail aumente con le tue esigenze... Vai oltre i 5GB



  
_
Più spazio per le tue esigenze. Hotmail va oltre i 5GB
http://www.windowslive.it/hotmail/SpazioDisponibile.aspx

[fw-general] Zend_Navigation and 'onclick'

2010-03-19 Thread Rocco Bruyn
Hi all,

 

I'm working on a project which (surprisingly) has pages and a navigation
menu.

The 'elbows' in the menu are not clickable. They just expand the underlying
sub-pages.

This works fine by creating a Zend_Navigation_Page_Uri with an uri '#'.

But the browser still responds to the click which I want to prevent by
adding an attribute onclick="return false".

I can't seem to figure out how to do this. Most simple case would be:

 

$nav = new Zend_Navigation(array(

  array(

'label'   => 'Folder',

'uri' => '#',

'onclick' => 'return false'

  )

));

 

$helper = new Zend_View_Helper_Navigation_Menu();

$helper->setView(new Zend_View());

 

echo $helper->render($nav);

 

But doesn't work as expected.

Can anyone shed a light on this?

 

Regards,

Rocco

 

 

 



[fw-general] HTTP response code when not logged in

2010-03-19 Thread Marian Meres
Hello everyone,

what kind of HTTP response codes would you suggest using when
accessing a page which requires user to be logged in and there is no
current identity present?

Initially I thought about "401 Unauthorized", but the definition says:
"The response MUST include a WWW-Authenticate header field containing
a challenge applicable to the requested resource" where I'm not sure I
know what that means...

I also thought about "403 Forbidden", but again from the definition:
"Authorization will not help and the request SHOULD NOT be repeated"
does not look like a good choice.

Or forget it and stick with good old "200 OK"?

Thanks,
M.