Best Zend Framework Architecture for a Big Reporting Site?

I have a website with about 60 tabular report pages. Want to convert this to Zend. A report consists of two states: an empty report and is filled with data. Each report has its own set of input fields and selects drop-down lists to narrow the search. You click the submit button and retrieve the data. What each page does.

Can I create 60 controllers with each of them with a default index action and getData action? Everything that I read on the Internet does not really describe how to architect a real site.

+4
source share
1 answer

If the method of extracting and retrieving data is quite similar, as you indicate between all 60 reports. It would be foolish to create 60 controllers (+ PHP files).

It seems that you are trying to solve this problem with the default rewrite router. You can add a route to the router that will automatically save your report name, and you can abstract and delegate this logic to some element report-runner-business-object-thingy.

$router = $ctrl->getRouter(); // returns a rewrite router by default $router->addRoute( 'reports', new Zend_Controller_Router_Route('reports/:report_name/:action', array('controller' => 'reports', 'action' => 'view')) ); 

And something like this in your controller ...

 public function viewAction() { $report = $this->getRequest()->getParam("report_name"); // ... check to see if report name is valid // ... stuff to set up for viewing report... } public function runAction() { $report = $this->getRequest()->getParam("report_name"); // ... check to see if report name is valid // Go ahead and pass the array of request params, as your report might need them $reportRunner = new CustomReportRunner( $report, $this->getRequest()->getParams() ); $reportRunner->run(); } 

You get the point; hope this helps!

+3
source

Source: https://habr.com/ru/post/1310700/


All Articles