Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7672579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:19:08+00:00 2026-05-31T16:19:08+00:00

Should the server or network shares be accessed via the controller directly or some

  • 0

Should the server or network shares be accessed via the controller directly or some kind of model created?

I can use code like this in the controller:

$path = '/var/www/uploads';
$fileArray = array();
$dir = new DirectoryIterator($path);
foreach ($dir as $fileinfo) {
  if (!$fileinfo->isDot()) {
    $fileArray[] = array('filename' => $fileinfo->getFilename(), 'extension' => $fileinfo->getExtension(), 'size' => $this->bytesToSize($fileinfo->getSize(),2), 'modified' => date('d/m/Y H:i', $fileinfo->getMTime())); 
  }
}
$this->view->fileList = $fileArray;

This would mean repeating every time which seems the wrong way to do things in MVC. Should I be creating a model that maps the file system, or does Zend have domething that can do this?

e.g. //PSEUDO CODE

$directory = new Zend_Directory();
$this->view->filelist = $directory->listFiles();
$directory->addFile('filepath');
$directory->deleteFile('filepath');

With similar sorts of functionality, upload, delete, rename, move, copy, etc.

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T16:19:09+00:00Added an answer on May 31, 2026 at 4:19 pm

    Make it a model. That way you can do unit tests, easily swap out new controllers, and reuse the model in other projects.

    A good rule of thumb is: If it directly interacts with data (a database, a service, a file, etc.), make it a model.

    And there actually is a proposal for Zend_Directory and Zend_File (link), but it doesn’t look like any work has been done on it since 2009.

    You might want to consider packaging your code as a plugin that others can use. Maybe use the link I posted above as a starting point.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing a library which you can use in client or server code. More
I have the problem, that MSSQL Server 2000 should select some distinct values from
In sql server ... Should I maintain stored procedures via the object broswer in
What is the minimum set of HTTP verbs that a server should allow for
I'm developing a server that should receive nightly reports from hundreds of business units.
I'm currently looking at which build server we should run up for a multi-platform
I am building a search box (input field) which should make a server call
Should you do validation on the server side, or is it ok to just
Should it be on the development servers or a Subversion server? I suppose this
Or should I be using a totally different server?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.