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

  • SEARCH
  • Home
  • 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 6933393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:49:38+00:00 2026-05-27T11:49:38+00:00

I’m working with a PHP MVC Framework. Works really well. I like the separation

  • 0

I’m working with a PHP MVC Framework. Works really well. I like the separation of the business layer (model) with the business logic (controller). But i just stumbled upon a problem. Here’s the thing:

Suppose i navigate to the following url:
http://localhost/user/showall/

In this case the userController.php is called and within that file there is a method showallAction() which gets executed.

In the showallAction() method i simply do a request to a model which gets all the users for me. Something like this:

public function showallAction()
{
    // create userModel object
    $users = new userModel();

    // get all users and assign the data to a variable which can be accessed in the view
    $this->view->users = $users->getAllUsers();

    // render views
    $this->view->render();
}

So this method gets all the users, assigns the data returned from the userModel to a variable and i can easily work with the returned data in my view. Just a typical MVC thing.

Now here comes the problem.
I also need to create a native iphone variant. Ofcourse the looks will be totally different. So all i actually want to do is to request this url:

http://localhost/user/showall/

And that it just gives me the array (in json format) back. So i can use that for the mobile development.

But this obviously can’t be done right now because the showallAction() method assumes that it is for web browser display. It doesn’t echo JSON formatted, instead it simply assings the array of users to a variable.

So that means i have to create another method “showallMobileAction()” in order to get the data, but specifically for the mobile device. But this is not an elegant solution. I’m sure that are better ways…

Anyone any idea how can i solve this problem??

  • 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-27T11:49:39+00:00Added an answer on May 27, 2026 at 11:49 am

    In your situation i would modify the routing mechanism.

    It would be useful, if you could add extension at the end of URL, which represents the format you expect, like :

    http://foo.bar/news/latest       >> HTML document
    http://foo.bar/news/latest.html  >> HTML document
    http://foo.bar/news/latest.rss   >> you RSS feed
    http://foo.bar/news/latest.json  >> data in JSON format 
    

    It’s a simple pattern to recognize. And you can later expand this to add .. dunno .. pdf output, or Atom feeds.

    Additionally , two comments :

    1. Model is not a type of objects. Instead it is a layer, containing objects responsible for business logic, and objects responsible for data storage/retrieval.

    2. View should be a full blown object, to which you bind the domain objects (objects responsible for business logic).

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I would like to count the length of a string with PHP. The string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;

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.