Are PHP includes almost as good as having a CMS?

by 16 replies
19
I am just learning to use PHP includes for updating menus, headers and footers in a CSS/HTML layout, but as for updating I almost find the concept as fast as updating a WP or Joomla site, but having much more design control over the look and feel.

Is this a reasonable statement about using PHP includes?
#programming #cms #good #includes #php
  • I actually use php includes for some of my sites simply because it's simpler for me (plus the fact that my internet connection may be crawling at times). I would see this as more of a personal preference. People with no knowledge of html/css will opt for wordpress since that's simpler for them. I on the other hand can setup a site much faster with php includes.

    But if I foresee a site having a lot of pages, I certainly would just use wordpress. Much easier in the long run and you could have a writer posting for you if needed.
  • PHP is a language.

    CMS is a system written in language (usually PHP)

    PHP includes is patch-work, while installing full-blown CMS would be whole solution.


    IF having CMS/Wordpress is like speaking a second language, then using bits and pieces of PHP code (sporadically) is like walking around with a dictionary.


    PHP includes are good when you need to include dynamic file and you don't want to update 20 pages to reflect changes (as person above me stated).

    CMS is Content Management System, meaning it's whole website designed for dynamic content.
  • A website made with php includes is easy to update sitewide. I like this method a lot when I want design versatility that is easy and fast to do.
    • [1] reply
    • I don't think it's appropriate to speak poorly of a PHP solution just because it's simple.

      PHP Code:
      <?php
      pagetitle  'My easy to maintain website';
      include (
      'header.php');
      ?>

      <h1>Welcome to my website</h1>
      <p>I write it using basic PHP and HTML and it works wonderfully!</p>

      <?php
      include ('footer.php');
      ?>
      You could have a great website using code as simple as that. I did just that a several years ago.

      The bonus is that it would load way faster than any Wordpress or CMS site.

      Sometimes a full CMS is "swatting a fly with a sledgehammer".

      -Ryan
      • [1] reply
  • Your question: Are PHP includes almost as good as having a CMS?
    My answer: What do you want to achieve?

    Can you make money by setting up a website which uses PHP includes to control menu, header and footer? Yes of course. You don't even need PHP includes to do that.

    However, a CMS isn't primarily designed to be a way to let you to change menu, header and footer.
    • Can you dynamically build a XML sitemap using PHP includes?
    • Can you dynamically create a tag cloud of your content using PHP includes?
    • Can you set up a comment system with captcha, automatic anti-spam and trackbacks using PHP includes?
    • Can you allow multiple users to update content on your website from any browser without knowing a thing about FTP, using PHP includes?
    • ...and so on.

    If you build simple websites and you just want to speed up the process of building them, then your way of using PHP includes to update the menu, header and footer... is a great idea!
    • [1] reply
    • I like a challenge!

      Yes, your sitemap.PHP could cycle through your folders and files on your website to generate a sitemap. No database required.

      This one's a little tougher, and you'd definitely want to cache the results, but yes... as long as you listed your tags in each page, you could still cycle through them all to make a tag cloud. (okay, I'm willing to give this one to CMS)

      This one is easy! Use a service like Disqus or Intense Debate to add comments with a single line of code in your footer.

      There are web-based programs that let you edit/manage your site files (as seen in cPanel's File Manager) But if multi-user is of importance, then ya... CMS.

      PHP can do it all. Of course, most CMS and Wordpress are built using PHP... so anything they can do PHP can do.. and sometimes do it better if not encumbered by un-used features.

      I love simplicity... even if it's more complex to set-up.

      So, back to the original point... Marty, if you're learning PHP I strongly encourage you to continue using it in it's "raw" form. Coding your own websites from scratch is not only fun, but you can get *just* what you want without unnecessary junk.

      -Ryan
      • [ 1 ] Thanks
      • [1] reply
  • Well, Mister Peacefull Warrior... it wasn't a challenge for me. In your reply, you're already starting to outline some of the functionality in a CMS :p

    The question still is "Are PHP includes almost as good as having a CMS?". What you are doing is something much more complex than PHP includes "for updating menus, headers and footers".

    But don't worry, relax, I get your point. And I can feel that you are really excited about it!

    As I said, it's a great idea to use PHP includes if the purpose is to produce simple websites and an easy way to update menu, header and footer.

    So again, it boils down to "What do you want to achieve?" as i posted previously.

    PS. I would never let some other service (Disqus or Intense Debate) be the owner of the valuable content on my website. You never know when they cut you off or go out of business.

    PS2. This was just too easy... give me a real challenge!
    • [ 1 ] Thanks
  • I do have a question, when it comes to flipping sites, would it be better to have the site in wordpress? I'm assuming that most individuals would be intimated with editing php/html files. And I'm assuming too that they want the ease of changing between themes.

    Basically, this just really boils down to whichever makes your life easier
  • If you're talking includes that are just layout based (i.e. include a nav menu or a header and footer) then you are definitely limited in the scope of what your site will be able to do.. but then, if that's all you really need, that's all you need... Now if your includes are also including function files and classes, then this is a different discussion all together. That's more of a custom cms vs existing cms discussion... so in my opinion it all boils down to what functionality you need currently and for your projected future growth.

    One pitfall to be wary of is of being so focused on the easy solution based on needs now rather than remember to have a scalable solution for the future. Having a roadmap early on can really save you some major hurdles and headaches later on.

    In essence, I'm really just agreeing with those before me that said it's based on the scope of your project and what your individual needs are.
  • The header, header.php:

    HTML Code:
    <html>
    <head>
    <title>How to Automatically Generate FLOODS Of Cash, Get The Nobel Prize Award And Save The Earth - No Work Required</title>
    <link rel="stylesheet" type="text/css" href="style.css" />
    </head>
    <body>
    <div><a href="home.php">Home</a> | <a href="about-me.php">About me</a></div>
    The content, home.php and about-me.php:
    PHP Code:
    <?php
    require_once("header.php");
    ?>
    <h1>Keep reading and you will be rich in NO time</h1>
    <p>Finally, after 10 years of research the scientists have cracked the code to eternal wisdom, everlasting happiness and the seductive skill of attracting red sports cars using nothing but your own magnetic powers of the Universe.</p>
    <?php
    require_once("footer.php");
    ?>
    The footer, footer.php:
    HTML Code:
    <div>Copyright &copy; 2010 MiracleCashTsunami Ltd.</div>
    </body>
    </html>
    I hope that will get you started

    What is your website project about?
  • To answer the original question of the OP:

    No. Includes are not as good as a CMS.

    Why?

    Simple. Imagine setting up a 10-50+ page site. No problem to update your menus and such with one file. That should be great.

    But now you want to change or add something that isn't in an included file. Now you have to do the very thing you wanted to avoid, which is open and edit every file in your site. Kinda counter-productive. Then you have to re-upload them to your server.

    Install your CMS once. Edit it right on the site. Enable scalability. All changes do not need to be re-uploaded. Add extra features with one click. Seems like a pretty easy solution.

    Does your site have less than 10 files and it won't ever get bigger? Just make a static site at that point. It almost seems like more work to incorporate includes anyway for a 10 page or less site.

    Just my two cents. And if people want to argue, go ahead. You're not changing my mind. I do this for a living.

    Later.
  • Yes Its same as using cms according to me but they have many other uses too of using includes
  • Banned
    [DELETED]

Next Topics on Trending Feed

  • 19

    I am just learning to use PHP includes for updating menus, headers and footers in a CSS/HTML layout, but as for updating I almost find the concept as fast as updating a WP or Joomla site, but having much more design control over the look and feel. Is this a reasonable statement about using PHP includes?