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 7859303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:51:59+00:00 2026-06-02T21:51:59+00:00

I am creating a custom MVC style framework from scratch and am at the

  • 0

I am creating a custom MVC style framework from scratch and am at the point where I need to implement the code to control what happens on POST.

At the moment I have a main index.php which acts as a controller and passes data to other controllers such as:

profilecontroller.class.php
forumcontroller.class.php

At the moment I see two options as to where the POST controllers can go ..

First Approach

Firstly for site wide posts such as login that can occur on any page I would use something like this in the very first index.php to redirect all POST to a specific POST controller that then sends the data to a model to be processed:

if($_POST)
    //post controller, works on specific form id's

Alternate Approach

The other option I see would be to build the POST identifier into the model construction sections but I don’t think this would be very manageable/wise as they’d always be checked and resulting in more loaded code?

Are there any good/simple examples out there?

I’m creating my mvc to be as light as possible so that’s my reason for going from scratch.

  • 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-06-02T21:52:00+00:00Added an answer on June 2, 2026 at 9:52 pm

    In a RESTful setup, you would normally have a controller for an object, say news, and then actions such as add, edit, delete etc.

    Within your actions, you should then assert what HTTP method should be used to access the method, if one should be. For example:

    <?php
    class NewsController extends AbstractController {
        public function save() {
            if ($_SERVER['REQUEST_METHOD'] != 'POST') {
                header('HTTP/1.1 405 Method Not Allowed');
                die('Please use POST.');
            }
            // carry on knowing we're working with a POST request
        }
    }
    

    Creating a separate controller for POST requests would, as you say, quickly becoming unruly and unmanageable.

    If you’re looking for a way of handling requests for different HTTP methods within different controller actions, then maybe check out ToroPHP. It’s a lightweight (single file) router, where you map a request to a class that’s referred to as a handler, and then that handler has methods for different HTTP methods. A quick example:

    <?php
    
    require 'lib/torophp/toro.php';
    require 'classes/handlers/HomeHandler.php';
    
    $toro = new ToroApplication(array(
        array('/', 'HomeHandler')
    ));
    $toro->serve();
    

    And then your HomeHandler would look as follows:

    <?php
    class HomeHandler {
        public function get() {
            echo 'Hello, world!';
        }
        public function post() {
            echo 'Try performing a GET request for the home page, buddy.';
        }
        // and so on...
    }
    

    Hope that helps.

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

Sidebar

Related Questions

I'm creating a custom MVC framework, but I'm stuck with some URL definitions in
while creating custom item renderers which interfaces we need to implement? Thank in advance.
I am in the middle of creating my own custom MVC web framework for
I am creating a custom MVC framework. I verrrrry loosely modeled it after the
I'm creating a custom MembershipProvider for an ASP.NET MVC website, and I was planning
Jython is great for creating custom data structures on need basis, but how to
I am creating a custom authentication service in my spring mvc application: @Service public
I have an ASP.NET MVC 2 application in which I am creating a custom
I am attempting to implement a custom locale service in an MVC 2 webpage.
There are two ways of creating a custom HTML helper in ASP.NET MVC: You

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.