Re: [fw-general] Random utility functions, where would they go?

2009-12-08 Thread Dan Field


On 7 Dec 2009, at 17:56, Mark Steudel wrote:


Over the years I've accumulated various functions that do little
utilities here and there, I'd still like to use them in my ZF project,
but I'm curious where would be the appropriate place to put them and
include them so they are available to my different controllers ...



How about creating your own library following the ZF conventions?

Here's what I have for example:

lib/Llgc/Wombat/Export/Document.php

Llgc is my place of work, Wombat is a piece of software we maintain  
and the Export /Document is a function I have written to support my  
work. Hope that makes sense.


and in the same lib dir I keep my ZF copy

e.g.

lib/Zend/Application/Exception.php

lib should already be in your include path (presuming you have ZF  
locally and not in a systemwide location like /usr/local/zend )


--
Dan FieldFfôn/Tel. +44 1970 632 582
Peiriannydd Meddalwedd  Senior Software Engineer
Llyfrgell Genedlaethol Cymru   National Library of Wales






Re: [fw-general] Sudden performance drop - server settings?

2009-12-02 Thread Dan Field


On 2 Dec 2009, at 08:44, Dan Field wrote:



On 2 Dec 2009, at 05:04, M@ wrote:


I've checked the following
-The hardware is newer and faster
-The connection to the db is great, and manual testing from the  
server shows

no issues with large amounts of connections/queries.
-The new server is not under heavy load.

The sysadmin for this new box swears it's setup identically to the  
old one -

yet I can find no other reasons for the problems.  Are there specific
PHP/Zend settings at the apache/php level that can totally hose PHP/ 
Zend
performance?  I know this is very vague - but I'm grasping at  
straws... I'm

looking for any known 'gotchas' for Zend on a new apache/php server.


It's probably nothing to do with ZF and more to do with the fine  
tuning in your php.ini file. I'd be looking at the resource limits  
section:


;;;
; Resource Limits ;
;;;

max_execution_time = 30 ; Maximum execution time of each script,  
in seconds
max_input_time = 60 ; Maximum amount of time each script may  
spend parsing request data

max_input_nesting_level = 64 ; Maximum input variable nesting level
memory_limit = 128M  ; Maximum amount of memory a script may  
consume (128MB)


and turn on all error reporting so you know a bit more about what is  
causing timeouts.


error_reporting = E_ALL & ~E_NOTICE

Are you tailing web server logs. These will give you more info to  
work from?



Oh, and you'll want to enable these too for debugging purposes:

log_errors = On

and maybe this one if you prefer to see the errors in the browser  
rather than in log files

display_errors = On

This could be useful too

report_memleaks = On


--
Dan FieldFfôn/Tel. +44 1970 632 582
Peiriannydd Meddalwedd  Senior Software Engineer
Llyfrgell Genedlaethol Cymru   National Library of Wales






Re: [fw-general] Sudden performance drop - server settings?

2009-12-02 Thread Dan Field


On 2 Dec 2009, at 05:04, M@ wrote:


I've checked the following
-The hardware is newer and faster
-The connection to the db is great, and manual testing from the  
server shows

no issues with large amounts of connections/queries.
-The new server is not under heavy load.

The sysadmin for this new box swears it's setup identically to the  
old one -

yet I can find no other reasons for the problems.  Are there specific
PHP/Zend settings at the apache/php level that can totally hose PHP/ 
Zend
performance?  I know this is very vague - but I'm grasping at  
straws... I'm

looking for any known 'gotchas' for Zend on a new apache/php server.


It's probably nothing to do with ZF and more to do with the fine  
tuning in your php.ini file. I'd be looking at the resource limits  
section:


;;;
; Resource Limits ;
;;;

max_execution_time = 30 ; Maximum execution time of each script,  
in seconds
max_input_time = 60 ; Maximum amount of time each script may spend  
parsing request data

max_input_nesting_level = 64 ; Maximum input variable nesting level
memory_limit = 128M  ; Maximum amount of memory a script may  
consume (128MB)


and turn on all error reporting so you know a bit more about what is  
causing timeouts.


error_reporting = E_ALL & ~E_NOTICE

Are you tailing web server logs. These will give you more info to work  
from?




--
Dan FieldFfôn/Tel. +44 1970 632 582
Peiriannydd Meddalwedd  Senior Software Engineer
Llyfrgell Genedlaethol Cymru   National Library of Wales






Re: [fw-general] Autoloader doesn't work properly

2009-11-26 Thread Dan Field
It's not due to the fact that you have used 2 underscore characters  
instead of just the 1 which is usual for protected methods is it? I  
know that Zend_Application looks for functions named initSomething but  
I don't know the expression it uses to identify them.


On 25 Nov 2009, at 17:24, Jigal Sanders wrote:


Thats exactly how i have it in zf version 1.9.5

On 25 nov 2009, at 18:18, Matthew Weier O'Phinney   
wrote:



-- Jigal sanders  wrote
(on Wednesday, 25 November 2009, 05:56 PM +0100):

Just created a project with zend tool.

In my bootstrap file I have :

protected function __initAutoload(){

  $autoloader = new Zend_Application_Module_Autoloader(array(
  'namespace' => '',
  'basePath'  => APPLICATION_PATH,
  ));
  return $autoloader;
  }

Now i have in my folder "application/forms" a file LoginForm.php.
in it is a class called class Form_LoginForm extends Zend_Form.

Now when i do in my controller $form = new Zend_LoginForm()

i get Fatal error: Class 'Form_LoginForm' not found in K:\xampp 
\htdocs\nrka\

application\controllers\AuthenticationController.php on line 22


I'm a bit confused -- what is the class called, and how are you  
trying

to invoke it? Based on the information you've provided, it should be:

  application/
  forms/
  LoginForm.php -> contains class Form_LoginForm

This should work, based on the information provided. If it doesn't,  
can

you please indicate what version of ZF you are using?

--
Matthew Weier O'Phinney
Project Lead| matt...@zend.com
Zend Framework  | http://framework.zend.com/


--
Dan FieldFfôn/Tel. +44 1970 632 582
Peiriannydd Meddalwedd  Senior Software Engineer
Llyfrgell Genedlaethol Cymru   National Library of Wales






[fw-general] Unit Testing Zend_Application SOAP server

2009-11-25 Thread Dan Field

I'm trying to use PHPUnit to test my Zend_Framework based SOAP server.

It's a simple application which has no controllers or views (too much  
overhead), but it does use the Zend_Application and bootstrap model,  
so I've been trying to use Zend_Test_PHPUnit_ControllerTestCase as it  
is Zend_Application aware.


My application bootstrap looks like this: http://pastebin.com/m6971312e
My application index.php looks like this: http://pastebin.com/m3feae19a

then on the PHPUnit side of things I have a smaller Bootstrap: 
http://pastebin.com/m7b61b419

and my test class http://pastebin.com/m40d5528c

Now my SOAP server works fine as a Zend_Application and I can view the  
wsdl being generated and can test from a cli soap client but the Unit  
Testing environment isn't getting set up correctly and when I run my  
unit tests I'm getting SOAP errors, which are probably related to a  
data backend problem which is due to the environment not being set up  
the same way as the app Bootstrap. But it should be as far as I can  
tell. All the code is the same between the unit test bootstrap and the  
app bootstrap.


Any ideas?

tests looks like this at present

macdanosx:~/Sites/webservicewombat/tests dof$ phpunit SoapServerTest
PHPUnit 3.4.3 by Sebastian Bergmann.

PHP Warning:  Cannot modify header information - headers already sent  
by (output started at /usr/local/zend/share/pear/PHPUnit/Util/ 
Printer.php:173) in /usr/local/zend/share/ZendFramework/library/Zend/ 
Soap/Server.php on line 829
PHP Warning:  Cannot modify header information - headers already sent  
by (output started at /usr/local/zend/share/pear/PHPUnit/Util/ 
Printer.php:173) in /usr/local/zend/share/ZendFramework/library/Zend/ 
Soap/Server.php on line 829
PHP Warning:  Cannot modify header information - headers already sent  
by (output started at /usr/local/zend/share/pear/PHPUnit/Util/ 
Printer.php:173) in /usr/local/zend/share/ZendFramework/library/Zend/ 
Soap/Server.php on line 829


http://schemas.xmlsoap.org/soap/envelope/ 
">Senderfaultcode>Invalid XMLSOAP-ENV:Body>



if I comment the parent::setUp()  line I get to the tests, albeit  
failed tests (they probably should work!)


macdanosx:~/Sites/webservicewombat/tests dof$ phpunit SoapServerTest
PHPUnit 3.4.3 by Sebastian Bergmann.

.EE.EEE

Time: 0 seconds

There were 5 errors:

1) SoapServerTest::testGetProject
SoapFault: Unknown error

/Users/dof/Sites/webservicewombat/tests/SoapServerTest.php:44

2) SoapServerTest::testGetPhase
SoapFault: Unknown error

/Users/dof/Sites/webservicewombat/tests/SoapServerTest.php:49

3) SoapServerTest::testGetPageItem
SoapFault: Unknown error

/Users/dof/Sites/webservicewombat/tests/SoapServerTest.php:59

4) SoapServerTest::testPageItems
SoapFault: Call to a member function toArray() on a non-object

/Users/dof/Sites/webservicewombat/tests/SoapServerTest.php:64

5) SoapServerTest::testGetTaskStatus
SoapFault: Call to a member function toArray() on a non-object

/Users/dof/Sites/webservicewombat/tests/SoapServerTest.php:69

FAILURES!
Tests: 7, Assertions: 2, Errors: 5.


--
Dan FieldFfôn/Tel. +44 1970 632 582
Peiriannydd Meddalwedd  Senior Software Engineer
Llyfrgell Genedlaethol Cymru   National Library of Wales






[fw-general] Best Practice for Dev/Build environment with ZF and PHP tools

2009-10-15 Thread Dan Field
I'm wondering if I am utilising the tools available to me to the best  
of their ability.


I currently develop locally on my Mac where I run a Zend Server  
implementation running out of /usr/local


This is where I edit code live. My svn working directory. It is also a  
DocumentRoot for a vhost on apache so I can see the changes live  
without having to commit/build them.


I also use Zend_Config in my projects and use phing to build these  
config files dependant on where the code is being deployed. (multiple  
properties files). However, the local instance I develop with also  
needs config files to operate, but these are not built by phing.


I just feel as though I'm not quite doing things in the best way. Can  
anyone offer any improvements to my setup? How do you work? I'm  
curious :)


--
Dan FieldFfôn/Tel. +44 1970 632 582
Peiriannydd Meddalwedd  Senior Software Engineer
Llyfrgell Genedlaethol Cymru   National Library of Wales






[fw-general] select ... from ... where ... in

2008-07-04 Thread Dan Field
Anybody know how I might use the 'in' syntax from MySQL to produce the  
following nested query using Zend_Db ?


select
d_articleid, d_divid, d_pageid
from
wjo_div
where
d_articleid in (
select
a_articleID
from
wjo_article
where
a_articlecode like '%001' and
a_publicationID = 037
)
order by
        d_pageid;


--
Dan Field <[EMAIL PROTECTED]>   Ffôn/Tel. +44 1970 632 582
Peiriannydd Meddalwedd Software Engineer
Llyfrgell Genedlaethol Cymru   National Library of Wales





Re: [fw-general] Zend_Pdf_FileParser_Image_Jpeg ... missing?

2007-11-15 Thread Dan Field


On 14 Nov 2007, at 18:01, Kevin McArthur wrote:


Dan,

Jpegs are supported through GD.

Use the factory method Zend_Pdf_Image::imageWithPath('/path/to/ 
file.jpg');


The image handling classes in Zend PDF are undergoing transitioning  
and should not be directly used.


Thanks Kevin. I want to avoid creating a file during this process. I  
have an Image class which returns me a string representation of the  
JPEG, and would have preferred the option of handing a string to  
Zend_Pdf_Image rather than a filename. I guess I'm out of luck until  
the FileParser class gets finished.


--
Dan Field <[EMAIL PROTECTED]>   Ffôn/Tel. +44 1970 632 582
Peiriannydd Meddalwedd Software Engineer
Llyfrgell Genedlaethol Cymru   National Library of Wales





[fw-general] Zend_Pdf_FileParser_Image_Jpeg ... missing?

2007-11-14 Thread Dan Field
Zend_Pdf_FileParser_Image_Jpeg does not sem to be part of my 1.0.2  
distribution. I wanted to create a PDF of images but use a string  
rather than a filename to add the images. I decided to copy a little  
code from Zend/Pdf/Image.php but I ran out of luck when I only found  
that the PNG parser has been written.


This is what I wanted to do:

class PDFDocument {
protected $pdf;

public function __construct() {
$this->pdf = new Zend_Pdf();
}

public function generatePDF($images) {

$this->pdf->pages = array_reverse($this->pdf->pages);

foreach ($images as $imageName) {
$this->pdf->page = $this->pdf->newpage 
(Zend_Pdf_Page::SIZE_A4);

$image = new Image($imageName);
$imgStream = $image->resizeWithRatio(0.4,0.4);

$dataSource = new Zend_Pdf_FileParserDataSource_String 
($imgStream);
$imageParser = new Zend_Pdf_FileParser_Image_Jpeg 
($dataSource);

$pdfJPEG = new Zend_Pdf_Resource_Image_Jpeg($imageParser);

$this->pdf->page->drawImage($pdfJPEG, 10, 10, 10, 10);

$this->pdf->pages[] = $this->pdf->page;
}
$this->pdf->render();
}
}

Am I out of luck for generating PDFs from JPEGs at this moment in time?

--
Dan Field <[EMAIL PROTECTED]>   Ffôn/Tel. +44 1970 632 582
Peiriannydd Meddalwedd Software Engineer
Llyfrgell Genedlaethol Cymru   National Library of Wales





Re: [fw-general] Zend Layout: Action Controller unable to disable Layout

2007-11-12 Thread Dan Field


On 12 Nov 2007, at 15:46, Matthew Weier O'Phinney wrote:

I've run into a small problem now where the layout stops getting  
rendered

right after my echo statement in this code segment bellow.


 

layout()->content; ?>




Those last 3 tags (or anything else I try and echo or hard code)  
never

render in the browser.


Try this instead for grabbing the content:

placeholder('Zend_Layout')->content ?>

and let me know if that works. If so, I need to make some changes  
to the

layout view helper.


Hi Matthew. Yes that worked perfectly. Many thanks.

Hope it doesn't mean too much work for you :)

--
Dan Field <[EMAIL PROTECTED]>   Ffôn/Tel. +44 1970 632 582
Peiriannydd Meddalwedd Software Engineer
Llyfrgell Genedlaethol Cymru   National Library of Wales





Re: [fw-general] Zend Layout: Action Controller unable to disable Layout

2007-11-12 Thread Dan Field


On 12 Nov 2007, at 13:01, Matthew Weier O'Phinney wrote:


-- Dan Field <[EMAIL PROTECTED]> wrote
(on Monday, 12 November 2007, 10:11 AM +):
After some advice on this list last week I've been looking at Zend  
Layout,
and it does everything I need except one single action in my  
project (which

renderds a JPEG and therefore does not require a layout).

I'm getting the following error:

PHP Fatal error:  Call to undefined method
Zend_Layout_Controller_Action_Helper_Layout::disableLayout() in
/var/www/proficcymod/application/controllers/TestController.php on  
line 39


Line 39 reads:

$this->_helper->layout->disableLayout();


Call the layout helper as a method call:

$this->_helper->layout()->disableLayout();

Doing that calls the direct() method of the helper, which in turn
proxies to the getLayout() method, which returns the layout object
itself. I did it this way instead of writing a number of methods that
simply proxy to the object itself; now you have access to the entire
layout object.


Thanks Mathew. That is a little neater.

I've run into a small problem now where the layout stops getting  
rendered right after my echo statement in this code segment bellow.



 

layout()->content; ?>




Those last 3 tags (or anything else I try and echo or hard code)  
never render in the browser.


--
Dan Field <[EMAIL PROTECTED]>   Ffôn/Tel. +44 1970 632 582
Peiriannydd Meddalwedd Software Engineer
Llyfrgell Genedlaethol Cymru   National Library of Wales





Re: [fw-general] Zend Layout: Action Controller unable to disable Layout

2007-11-12 Thread Dan Field


On 12 Nov 2007, at 10:28, Simon Mundy wrote:


$this->_helper->layout->getLayout()->disableLayout()


Thats fixed it. Cheers. Looks like the wiki docs are out of date.



--
Dan Field <[EMAIL PROTECTED]>   Ffôn/Tel. +44 1970 632 582
Peiriannydd Meddalwedd Software Engineer
Llyfrgell Genedlaethol Cymru   National Library of Wales





[fw-general] Zend Layout: Action Controller unable to disable Layout

2007-11-12 Thread Dan Field
After some advice on this list last week I've been looking at Zend  
Layout, and it does everything I need except one single action in my  
project (which renderds a JPEG and therefore does not require a layout).


I'm getting the following error:

PHP Fatal error:  Call to undefined method  
Zend_Layout_Controller_Action_Helper_Layout::disableLayout() in /var/ 
www/proficcymod/application/controllers/TestController.php on line 39


Line 39 reads:

$this->_helper->layout->disableLayout();

I have the following includes at the top of the controller class:

require_once 'Zend/Layout.php';
require_once 'Zend/Layout/Controller/Action/Helper/Layout.php';

And my include path is set up like so:

php_value include_path "../lib/ZFIncubator:../lib/LLGC:/usr/local/ 
ZendFramework-1.0.2/library/"


I'm stumped. I tried altering the line to read:

$this->_helper->getLayout()->disableLayout();

but obviously helpers don't work like regular classes as I would have  
expected me to be able to return a Layout instance but instead it  
tries to locate a layout called getLayout!



--
Dan Field <[EMAIL PROTECTED]>   Ffôn/Tel. +44 1970 632 582
Peiriannydd Meddalwedd Software Engineer
Llyfrgell Genedlaethol Cymru   National Library of Wales





Re: [fw-general] Placeholders in View Scripts

2007-11-09 Thread Dan Field


On 9 Nov 2007, at 09:17, Dan Field wrote:

Imagine a fairly typical header, left menu, right content area,  
footer type layout:


you have a _header.phtml file which you include in all view scripts  
and likewise for the footer. You also create the _left_menu.phtml  
view script and include this in the header. All other scripots just  
include the _header and _footer. My question is: How can I go back  
and put some page dependend content into the left menu bar when  
It's been created already by the header?


To answer my own question, it would seem that ViewRenderer and  
Layouts is what I was after.


http://akrabat.com/2007/06/02/extending-viewrenderer-for-layouts/

--
Dan Field <[EMAIL PROTECTED]>   Ffôn/Tel. +44 1970 632 582
Peiriannydd Meddalwedd Software Engineer
Llyfrgell Genedlaethol Cymru   National Library of Wales





[fw-general] Placeholders in View Scripts

2007-11-09 Thread Dan Field
Imagine a fairly typical header, left menu, right content area,  
footer type layout:


you have a _header.phtml file which you include in all view scripts  
and likewise for the footer. You also create the _left_menu.phtml  
view script and include this in the header. All other scripots just  
include the _header and _footer. My question is: How can I go back  
and put some page dependend content into the left menu bar when It's  
been created already by the header?



_header:
foo bar metadata etc...

include('_left_menu')



_left_menu:

  lots of menu related code
  
In here I would like to display content dependent on the action  
being performed

  



_footer:
 

--
Dan Field <[EMAIL PROTECTED]>   Ffôn/Tel. +44 1970 632 582
Peiriannydd Meddalwedd Software Engineer
Llyfrgell Genedlaethol Cymru   National Library of Wales





Re: [fw-general] Route problem

2007-11-08 Thread Dan Field


On 8 Nov 2007, at 17:53, Michał Minicki wrote:


Dan Field wrote:


$router->addRoute('pages', $testhighlightingRoute);
$router->addRoute('pages', $testdisplayimageRoute);
It's as if the second route is overwriting the first one some  
how.  Any ideas? I'm stumped.


That's exactly what happened because you named both of the routes  
the same - 'pages'. This name is used internally as an array key  
for the routes collection.


Ah! So every route needs a unique identifier here?

Many thanks for the quick reply. That has fixed it all :)

--
Dan Field <[EMAIL PROTECTED]>   Ffôn/Tel. +44 1970 632  
582

Peiriannydd Meddalwedd Software Engineer
Llyfrgell Genedlaethol Cymru   National Library of Wales





[fw-general] Route problem

2007-11-08 Thread Dan Field
I've been playing with 2 new test scripts today and I have the  
following routers set in the bootstrap:


// Test Highlighting Router
$testhighlightingRoute = new Zend_Controller_Router_Route(
'/test/highlight/:id/:ratio/:xmldoc/:term',
array(
'module'=> 'default',
'controller'=> 'test',
'action'=> 'highlight'
)
);
$router->addRoute('pages', $testhighlightingRoute);

// Test Display Image Router
$testdisplayimageRoute = new Zend_Controller_Router_Route(
'/test/displayimage/:id/:ratio',
array(
'module'=> 'default',
'controller'=> 'test',
'action'=> 'displayimage'
)
);
$router->addRoute('pages', $testdisplayimageRoute);

This morning I added the first router and when I was happy with the  
Action and Controller, I added the second router and set to work on  
that Action and Controller. However now I've gone back to the first  
controller and it no longer works. None of the variables I'm allowing  
in the router (id, ratio,xmldoc,term) are getting set.


It's as if the second route is overwriting the first one some how.  
Any ideas? I'm stumped.


--
Dan Field <[EMAIL PROTECTED]>   Ffôn/Tel. +44 1970 632 582
Peiriannydd Meddalwedd Software Engineer
Llyfrgell Genedlaethol Cymru   National Library of Wales





[fw-general] Use of class member variables within controllers

2007-08-01 Thread Dan Field
I'm sure I read somewhere, that we should not create member variables  
in the controllers. Is this right? Is there an alternative? or have I  
got the wrong end of the stick somehow? Now I think about it, it  
might have been due to coding standards and the use of the var  
identifier? why is this wrong?


--
Dan Field <[EMAIL PROTECTED]>   Ffôn/Tel. +44 1970 632 582
Datblygwr Systemau Systems Developer
Llyfrgell Genedlaethol Cymru   National Library of Wales