The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other code snippets: best practice

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #41363

    I was thinking of adding a code snippet type area to my site, and I am wondering what the best way of doing it is.

    I have thought of a few ways to do this.
    The first is to store all files(css, php, java, ruby, etc.) in directories according to type.
    Then have php scan the directories and show them on the page.

    Or I could store all of the code in the database, which seems annoying.

    I could also have a static page that I edit whenever I add a new piece of code, this would load faster, but it would be annoying to maintain.

    What do you think??


    I think something like that depends on how many snippets you’ve got. If you’ve got loads then I’d look at the database option, or if you’re not wanting to down database drive you would look at JSON and have a PHP file read and display snippets.


    Of course! JSON! or perhaps YAML.

    Good one!


    Personally, I prefer JSON.

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘Other’ is closed to new topics and replies.