Jump to content

trq

Staff Alumni
  • Posts

    30,999
  • Joined

  • Last visited

  • Days Won

    26

Posts posted by trq

  1. The point I'm trying to make is why have the rewrite at all if you're just going to use normal querystring parameters? I understand you want to force everything through a front controller, but why stop there?

     

    But yeah, you could just use the QSA flag to have apache append existing parameters.

     

    RewriteRule ^(.*)$ index.php?uri=$1 [PT,L,QSA]
    
    • Like 1
  2. That rewrite rule removes the need for typical GET parameters by making your urls "pretty".

     

    So instead of this:

     

    users/activate-account?email_address=test&token=test
    
    You would use something more like:

     

    users/activate-account/test/test
    
    Of course then you need some sort of "router" to parse and handle these parameters for you.

     

    If this is your own framework you need to decide how your urls are going to be formed.

  3. I would rather not pass each given property on a need to use basis, but just pass the whole object.

    Why? The only reason to do this is laziness. It is making your code tightly coupled to whatever this "god" object is.

     

    A controller has no interest in your connection settings for instance.

     

    Objects should be passed their dependencies (and only their dependencies) at construction time.

     

    Most frameworks handle this in an easy to manage manor by providing a configurable dependency injection container which allows you to configure how objects are to be created.

  4. Your script is going to have to write to the index.php file.

    Easy way is to make a template file with a searchable tag you can do a find and replace on like: {{replace_text}}

    You open the file, search and replace the tags you want.

    Will need to set the permissions on that file to make it writeable.

    Then use functions like:

    fopen()

    preg_match() or str_replace()

    fclose()

    Why would you edit the index.php file? PHP is a programming language, you can use it to dynamically display data from different data sources. Having cron dynamically alter the PHP "script" is ridiculous.

     

    Instead, have your cron job put the data somewhere PHP can easily access it (like a database) and then write some logic into your php script to retrieve this data and display it.

    • Like 1
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.