Script47 Posted December 7, 2013 Share Posted December 7, 2013 May sound like a newbie question but how would one make a website modular? So separate it all in to different modules? Where could one learn about it? Quote Link to comment Share on other sites More sharing options...
sniko Posted December 7, 2013 Share Posted December 7, 2013 By using a clever design pattern. If you harness MVC effectively, you could make an application modular. Quote Link to comment Share on other sites More sharing options...
Coly010 Posted December 8, 2013 Share Posted December 8, 2013 By using a clever design pattern. If you harness MVC effectively, you could make an application modular. Yeah a design pattern is definitely essential. I think you might possibly be able to utilise a database for this. You'd also need a very could piece of code to search for modules, decompile them if they are in folders or packages and have them implement into your site seemlessly. With a database you could have a system to turn them on / off, have the url to the package etc. I don't know if PHP would be the best language for this tbh, it can be done, but how about looking into ASP.NET? You should have more functionality with that, it might make it a little bit easier, even if the only piece of ASP.NET code is to add / remove the modules, or process them. Quote Link to comment Share on other sites More sharing options...
sniko Posted December 8, 2013 Share Posted December 8, 2013 Yeah a design pattern is definitely essential. I think you might possibly be able to utilise a database for this. You'd also need a very could piece of code to search for modules, decompile them if they are in folders or packages and have them implement into your site seemlessly. With a database you could have a system to turn them on / off, have the url to the package etc. I don't know if PHP would be the best language for this tbh, it can be done, but how about looking into ASP.NET? You should have more functionality with that, it might make it a little bit easier, even if the only piece of ASP.NET code is to add / remove the modules, or process them. Why would you need to adopt another language to enable/disable modules? There is plenty of ways/hacks to do it; A database table, like you said. Create a "disabled" file in the module folder Create a "list" of disabled modules in a configuration file Rename the module folder Quote Link to comment Share on other sites More sharing options...
KyleMassacre Posted December 8, 2013 Share Posted December 8, 2013 correct! take nwe or panther :p for example. they are basically ran of an index file for the most part, they just include $_GET["module_name"]/index.php if that's what you mean ;) Quote Link to comment Share on other sites More sharing options...
Coly010 Posted December 8, 2013 Share Posted December 8, 2013 Honestly sniko, I was simply doubting the power of PHP for the task, but since I've never tried it I couldn't know for certain. I did say in my post that it could be done in PHP as I was aware of NWE and its modular structure. Ah well, I think there is enough here to get the OP thinking about his approach to this. Quote Link to comment Share on other sites More sharing options...
Joel Posted December 14, 2013 Share Posted December 14, 2013 I developed a PHP Modular MVC Framework, also supports themes so you can have multiple templates. Released under the MIT license, check: https://github.com/Jo3la/Modular-MVC-Framework Does not require a database connection to work. Quote Link to comment Share on other sites More sharing options...
Guest Posted December 14, 2013 Share Posted December 14, 2013 I developed a PHP Modular MVC Framework, also supports themes so you can have multiple templates. Released under the MIT license, check: https://github.com/Jo3la/Modular-MVC-Framework Does not require a database connection to work. Nice little engine, I have taken a look, do you intend to give any examples on the Database? Do you plan on extending it? The modular layout is good. Nice simple template system, autoloading, definatly a good start. Quote Link to comment Share on other sites More sharing options...
Joel Posted December 14, 2013 Share Posted December 14, 2013 Nice little engine, I have taken a look, do you intend to give any examples on the Database? Do you plan on extending it? The modular layout is good. Nice simple template system, autoloading, definatly a good start. Thanks, and yes the database class definitely needs work, currently only supports mysqli. Examples will come soon, the framework was released just yesterday. Quote Link to comment Share on other sites More sharing options...
KyleMassacre Posted December 14, 2013 Share Posted December 14, 2013 that would be nice to give people the option to what route they wish to go whether it be mysqli or pdo. But for the topic at hand I think a good file structure would be your best bet to creating a modular site and enforce the file structure. You don't want a ton of loose files in your directories, not saying you can't have any but those loose files would mainly be for the "core" of your framework. I know I keep bringing up NWE and may sound like a broken record but I feel its an excellent example of a modular framework so maybe take some notes from that especially since it lets you go many directories deep to grab files for use Quote Link to comment Share on other sites More sharing options...
Dominion Posted December 14, 2013 Share Posted December 14, 2013 Since MVC has been mentioned I suggest reading this - http://makewebgames.io/showthread.php/43178-MVC-or-not-MVC I would ask what you want to be modular, and why you are trying to learn about it? Honestly sniko, I was simply doubting the power of PHP for the task, but since I've never tried it I couldn't know for certain. I did say in my post that it could be done in PHP as I was aware of NWE and its modular structure. Ah well, I think there is enough here to get the OP thinking about his approach to this. This confused me a little. Surely you should decide what you want to do then select the best approach for it. Simply wanting something to be modular is hardly a sufficient explanation to say PHP is not the way to go without any context of what the program is going to be. Quote Link to comment Share on other sites More sharing options...
Coly010 Posted December 14, 2013 Share Posted December 14, 2013 This confused me a little. Surely you should decide what you want to do then select the best approach for it. Simply wanting something to be modular is hardly a sufficient explanation to say PHP is not the way to go without any context of what the program is going to be. Very true, I think I was talking out of my ass that stage. Quote Link to comment Share on other sites More sharing options...
Script47 Posted December 24, 2013 Author Share Posted December 24, 2013 So I've been messing with some code and think I've got the hang of it. Is it basically like this? index.php <?php include 'links.php'; if(isset($_GET['module'])) { include 'modules/'.$_GET['module'].'/index.php'; } links.php <?php echo '<a href="index.php?module=about">About</a>'; modules/about/index.php <?php echo 'Some about'; That module page even shows up, but it seems too easy to be true. So have I got the basic idea of it or have got it completely wrong? Quote Link to comment Share on other sites More sharing options...
KyleMassacre Posted December 24, 2013 Share Posted December 24, 2013 So I've been messing with some code and think I've got the hang of it. Is it basically like this? index.php <?php include 'links.php'; if(isset($_GET['module'])) { include 'modules/'.$_GET['module'].'/index.php'; } links.php <?php echo '<a href="index.php?module=about">About</a>'; modules/about/index.php <?php echo 'Some about'; That module page even shows up, but it seems too easy to be true. So have I got the basic idea of it or have got it completely wrong? Looks right but I would redirect them to a default page if the module query string isnt there Quote Link to comment Share on other sites More sharing options...
Script47 Posted December 24, 2013 Author Share Posted December 24, 2013 (edited) Looks right but I would redirect them to a default page if the module query string isnt there Yeah I have done, on mine that was something I just thought to make sure I was doing right, thanks Kyle. :) Edited December 24, 2013 by Script47 Quote Link to comment Share on other sites More sharing options...
Script47 Posted December 25, 2013 Author Share Posted December 25, 2013 If anyone is interested in how I did it then I will gladly put it on here. Just give me a shout. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.