PHP Mini-Framework (Need Suggestions)

Posted In PHP
  • james-geiger 3 years ago

    Hi,

    I just joined after viewing your tutoiral on YouTube about a registration/login site done in PHP. I am new to PHP so I do not want to learn MVC or Laravel at this time. I am focusing on core PHP and understanding everything first and thus, am writing my own min-framework based on your tutorial.

    My progress is here, but can you provide a little guidance on what my next steps should be? Should I:

    • Create a user.class.php that contains the user logic and all of that?
    • A session class?
    • A router class?

    I just want the basics and want the challange of writing my own, but can you provide some hints in the right directon on the minumum features I'll need for this small framework?

    Thanks!

  • tnylea 3 years ago

    Hey James,

    I think that's really cool that you want to build a mini-framework. As far as the features that you will need I think that kind of depends on how big you want the mini-framework to be, but here are some typical functionalities that are provided with a framework:

    • Routing Functionality
    • Database/Active Record implementation or Helper
    • Session/Cookie Helper Class

    I think the next step would definitely be a way to add Routing to your application. Some good ways to look at how to write a routing class might be to look at how some of the popular frameworks, such as CodeIgniter or Laravel do it.

    You could also take a look at the following code on how you might do a simple router:

    <?php
    // ******************** //
    // SETUP THE ROUTER
    // ******************** //
    // Get the current request URI
    $uri = $_SERVER['REQUEST_URI'];
    // Trim off any additional forward slashes
    $uri = trim( $uri, "/" );
    // Convert the URI parameters into an array
    $url = explode('/', $uri);
    // Set the default file to the home page
    $file = 'home';
    // if the first parameter exists
    if(!empty($url[0])):
    	// Set the file to be the first parameter
    	$file = $url[0];
    endif;
    // Create arguments and set it to the url parameters except the first
    array_shift($url);
    $args = $url;
    
    // LOAD THE VIEW
    if(file_exists($file . '.php')){
    	require $file . '.php';
    } else {
    	require '404.php';
    }

    Hope that helps and let me know if you have any questions about the code above :)

    Thanks again. I'm sure I could help you contribute a little to the mini-framework.

    Looking forward to hearing from you soon.

  • harriet-wallace 3 months ago
    Dude I seriously don’t know much about PHP framework. I myself want to [learn php](https://phptopics.com/), but I don’t know the best site or institution to learn this program. Learning this can be of a lot of use to me.
    

    Dude I seriously don’t know much about PHP framework. I myself want to learn php, but I don’t know the best site or institution to learn this program. Learning this can be of a lot of use to me.

  • susan-byrd 2 months ago
    Like different frameworks of, the body the vestibular frameworks working is likewise important to keep up the equalization of the body and fro the fortifying of this framework read this [https://www.bestessayservicereviews.com/essay-writing/ninjaessays-com-review/](https://www.bestessayservicereviews.com/essay-writing/ninjaessays-com-review/) in detail and pursue these tips from this commendable article imparted to us.

    Like different frameworks of, the body the vestibular frameworks working is likewise important to keep up the equalization of the body and fro the fortifying of this framework read this https://www.bestessayservicereviews.com/essay-writing/ninjaessays-com-review/ in detail and pursue these tips from this commendable article imparted to us.

Please login or signup to leave a response.

Login

or Sign Up

Sign Up

or Login
×
Want to create your own SAAS?

I can teach you to create your own Software as a Service. Click here to learn more!

Visit SAAS Adventure!