Skip to content

Instantly share code, notes, and snippets.

@InFog
Last active September 14, 2024 19:06
Show Gist options
  • Save InFog/2d5be2b1b4dd818333f6 to your computer and use it in GitHub Desktop.
Save InFog/2d5be2b1b4dd818333f6 to your computer and use it in GitHub Desktop.

Revisions

  1. InFog revised this gist Jul 6, 2017. 1 changed file with 9 additions and 7 deletions.
    16 changes: 9 additions & 7 deletions proceduralphp.md
    Original file line number Diff line number Diff line change
    @@ -5,23 +5,24 @@ We are web site developers (a.k.a. webmasters) and we just want to get stuff don
    And that's why our values are:

    1. **Procedural Code** over Object Orientation
    - No one actually needs OO to develop web applications
    - Classes with only *static* functions are ok, since it's just a way to keep functions in one place. And is still procedural
    2. **Explicitly load what you need** over autoloaders
    - Autoloaders are complex and can fail. Just include() what you need
    - Autoloaders are complex and can fail. Just `include_once()` what you need
    3. **One PHP file per URL** over Front Controller
    - Just include() **header.inc.php** and **footer.inc.php** in your files and everything will be ok
    - Just `include_once()` **header.inc.php** and **footer.inc.php** in your files and everything will be ok
    - And also, Front Controller reminds us of Controllers and MVC and this stuff is complicated
    4. **Inline MySQL queries** over Database Abstraction libraries
    - These libraries are usually OO, and we don't like OO

    And remember that we don't only add more value to the items on the left, we simply ignore the values on the right.
    And remember that we don't only give more value to the items on the left, we simply choose to ignore the values on the right.

    ## PHP Procedural Framework

    To make our dreams come true, we developed our own PHP Procedural Framework.
    This is the simplest PHP Framework around because we have no time to learn how to use the huge OO-DependencyInjection monsters that surround us.

    The framework is contained within just one file that you can include() in all your scripts (value #3):
    The framework is contained within just one file that you can `include_once()` in all your scripts (value #3):

    ```php
    <?php
    @@ -51,15 +52,15 @@ You can open 'phpprocedural.inc.php' to read our code, but you don't need to. Ou
    ```php
    <?php
    function gracefully_close_mysql_connection() {
    // My cousin told me that @ will avoid errors when there is no MySQL connections. Great!
    // A friend told me that '@' will avoid errors when there is no MySQL connections. Great!
    @ mysql_close();
    }
    ```

    ### Bonus! No more errors, now you can become a PHP Pro in no time!

    We all know that errors in the code, like undefined array keys are boring and only confusing for our clients and users.
    In the last version of our framework we added some magical lines that will make you a PHP Pro with no more errors display!
    We all know that errors in the code, like undefined array keys, are boring and only confusing for our clients and users.
    In the last version of our framework we added some magical lines that will make you a PHP Pro with no more errors showing up in no time!

    Here is how the magic is done:

    @@ -70,6 +71,7 @@ Here is how the magic is done:
    @ ini_set('error_reporting', 0);
    @ ini_set('display_errors', false);
    ```

    Join us! Spread the word! Use the tag #proceduralphp :)

    PS: This is just a joke -.-
  2. InFog revised this gist Jan 9, 2015. 1 changed file with 7 additions and 6 deletions.
    13 changes: 7 additions & 6 deletions proceduralphp.md
    Original file line number Diff line number Diff line change
    @@ -1,15 +1,15 @@
    # Procedural PHP Manifesto

    We are web site developers (a.k.a. webmasters) and we just want to get stuff done. We don't need Object Orientation and we don't Design Patters and other boring and not easy stuff to get in our way to get our sites up and running.
    We are web site developers (a.k.a. webmasters) and we just want to get stuff done. We don't need Object Orientation and we don't need Design Patters and other boring and not easy to learn and understand stuff to get in our way to get our sites up and running.

    And that's why our values are:

    1. **Procedural Code** over Object Orientation
    - Classes with only *static* functions are ok, since it's just a way to keep function in one place.
    - Classes with only *static* functions are ok, since it's just a way to keep functions in one place. And is still procedural
    2. **Explicitly load what you need** over autoloaders
    - Autoloaders are complex and can fail. Just include() what you need
    3. **One PHP file per URL** over Front Controller
    - Just include() header.php and footer.php in your files and everything will be ok
    - Just include() **header.inc.php** and **footer.inc.php** in your files and everything will be ok
    - And also, Front Controller reminds us of Controllers and MVC and this stuff is complicated
    4. **Inline MySQL queries** over Database Abstraction libraries
    - These libraries are usually OO, and we don't like OO
    @@ -58,8 +58,8 @@ function gracefully_close_mysql_connection() {

    ### Bonus! No more errors, now you can become a PHP Pro in no time!

    We all know that errors in the code, like undefined array keys are boring and only confusing for ours clients and users.
    In the last version of our framework we added some magical lines that will make you a PHP Pro with no more error displays!
    We all know that errors in the code, like undefined array keys are boring and only confusing for our clients and users.
    In the last version of our framework we added some magical lines that will make you a PHP Pro with no more errors display!

    Here is how the magic is done:

    @@ -70,5 +70,6 @@ Here is how the magic is done:
    @ ini_set('error_reporting', 0);
    @ ini_set('display_errors', false);
    ```
    Join us! Spread the word! Use the tag #proceduralphp :)

    This is just a joke -.-
    PS: This is just a joke -.-
  3. InFog revised this gist Dec 23, 2014. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions proceduralphp.md
    Original file line number Diff line number Diff line change
    @@ -6,12 +6,12 @@ And that's why our values are:

    1. **Procedural Code** over Object Orientation
    - Classes with only *static* functions are ok, since it's just a way to keep function in one place.
    2. *Explicitly load what you need* over autoloaders
    2. **Explicitly load what you need** over autoloaders
    - Autoloaders are complex and can fail. Just include() what you need
    3. *One PHP file per URL* over Front Controller
    3. **One PHP file per URL** over Front Controller
    - Just include() header.php and footer.php in your files and everything will be ok
    - And also, Front Controller reminds us of Controller, and MVC and this stuff is complicated
    4. *Inline MySQL queries* over Database Abstraction libraries
    - And also, Front Controller reminds us of Controllers and MVC and this stuff is complicated
    4. **Inline MySQL queries** over Database Abstraction libraries
    - These libraries are usually OO, and we don't like OO

    And remember that we don't only add more value to the items on the left, we simply ignore the values on the right.
  4. InFog revised this gist Dec 23, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion proceduralphp.md
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@ We are web site developers (a.k.a. webmasters) and we just want to get stuff don

    And that's why our values are:

    1. *Procedural Code* over Object Orientation
    1. **Procedural Code** over Object Orientation
    - Classes with only *static* functions are ok, since it's just a way to keep function in one place.
    2. *Explicitly load what you need* over autoloaders
    - Autoloaders are complex and can fail. Just include() what you need
  5. InFog revised this gist Dec 23, 2014. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions proceduralphp.md
    Original file line number Diff line number Diff line change
    @@ -4,14 +4,14 @@ We are web site developers (a.k.a. webmasters) and we just want to get stuff don

    And that's why our values are:

    1 - *Procedural Code* over Object Orientation
    1. *Procedural Code* over Object Orientation
    - Classes with only *static* functions are ok, since it's just a way to keep function in one place.
    2 - *Explicitly load what you need* over autoloaders
    2. *Explicitly load what you need* over autoloaders
    - Autoloaders are complex and can fail. Just include() what you need
    3 - *One PHP file per URL* over Front Controller
    3. *One PHP file per URL* over Front Controller
    - Just include() header.php and footer.php in your files and everything will be ok
    - And also, Front Controller reminds us of Controller, and MVC and this stuff is complicated
    4 - *Inline MySQL queries* over Database Abstraction libraries
    4. *Inline MySQL queries* over Database Abstraction libraries
    - These libraries are usually OO, and we don't like OO

    And remember that we don't only add more value to the items on the left, we simply ignore the values on the right.
  6. InFog created this gist Dec 23, 2014.
    74 changes: 74 additions & 0 deletions proceduralphp.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,74 @@
    # Procedural PHP Manifesto

    We are web site developers (a.k.a. webmasters) and we just want to get stuff done. We don't need Object Orientation and we don't Design Patters and other boring and not easy stuff to get in our way to get our sites up and running.

    And that's why our values are:

    1 - *Procedural Code* over Object Orientation
    - Classes with only *static* functions are ok, since it's just a way to keep function in one place.
    2 - *Explicitly load what you need* over autoloaders
    - Autoloaders are complex and can fail. Just include() what you need
    3 - *One PHP file per URL* over Front Controller
    - Just include() header.php and footer.php in your files and everything will be ok
    - And also, Front Controller reminds us of Controller, and MVC and this stuff is complicated
    4 - *Inline MySQL queries* over Database Abstraction libraries
    - These libraries are usually OO, and we don't like OO

    And remember that we don't only add more value to the items on the left, we simply ignore the values on the right.

    ## PHP Procedural Framework

    To make our dreams come true, we developed our own PHP Procedural Framework.
    This is the simplest PHP Framework around because we have no time to learn how to use the huge OO-DependencyInjection monsters that surround us.

    The framework is contained within just one file that you can include() in all your scripts (value #3):

    ```php
    <?php
    include('phpprocedural.inc.php');
    ```

    And that's all, super simple! Now you can use the life saving functions:

    ```php
    <?php
    connect_to_mysql();
    // In the first lines of 'phpprocedural.inc.php' you will find the config vars for connection

    include_script('header.php');
    // This function checks if the file exists, if not it shows an error

    show_webmaster('John Doe', '[email protected]');
    // Use this in the footer of the site. Displays something like this: Webmaster John Doe - ©Year - Visit Counter: 000004356
    // How can we count the visits? Don't worry, we just can ;)

    gracefully_close_mysql_connection();
    // Will close MySQL connections. We don't want open connections to me left there, right?
    ```

    You can open 'phpprocedural.inc.php' to read our code, but you don't need to. Our code is simple and awesome. Here is just a small part, if you want to know about our best practices:

    ```php
    <?php
    function gracefully_close_mysql_connection() {
    // My cousin told me that @ will avoid errors when there is no MySQL connections. Great!
    @ mysql_close();
    }
    ```

    ### Bonus! No more errors, now you can become a PHP Pro in no time!

    We all know that errors in the code, like undefined array keys are boring and only confusing for ours clients and users.
    In the last version of our framework we added some magical lines that will make you a PHP Pro with no more error displays!

    Here is how the magic is done:

    ```php
    <?php
    // Magically removes errors from the code
    @ error_reporting(0);
    @ ini_set('error_reporting', 0);
    @ ini_set('display_errors', false);
    ```

    This is just a joke -.-