Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[DEV] MapleStory Web Framework

Joined
Sep 8, 2011
Messages
822
Reaction score
129
Foundation
Foundation is a simple micro framework built in PHP OOP using Symfony components (httpKernel, httpFoundation, Routing), Laravel components (Blade templating) and others with PHP version >= 5.3 fully supported, including HHVM.
Foundation follows the MVC architecture and also make use of templates for a more clean and understandable View code, this will make life easier for people who wish to change the HTML template and redesign it by providing a total separation between front end (design) and back end (logic, functionality).



Why?
Simply because my Maple project will make use of several web apps and services including APIs, by working on this project I eliminate the need to redo the base (core, routing, http handling, error handling, logging, MVC, PDO & ORM, installation, etc) each time I need to work on a new web app/service, also this will help greatly to the MS pserver community simply because it will have public and very modular (easy to extend as well) CMS and it will be released eventually.


Build
Development Build: Alpha 1.0.0
Stable Build: Not available.
GitHub:

I ended up discarding everything I've done the past week or so for a new base, started this yesterday didn't work much, also it's quite a mess atm but it werks appropriately. Still need to clean it and make a Core class to handle most of it, implement Monolog logging, error handling, models, database interactions, translations, etc.


Contributors Hopefully the list will grow
@kingslime


Libraries
Composer - Packages management
Symfony - Most Components
Laravel - Blade Templating
The PHP League - Container package
Monolog - Logging package
 
Last edited:
Joined
Sep 8, 2011
Messages
822
Reaction score
129
Re: [ALPHA] Sporter Framework v2

Sporter v2 is now available on GitHub!
Sporter v1.5.1 has been moved to repository "SporterOLD".

Sporter v2 will be fully written in OOP, following a better structure design that will make our lives easier when developing it, no more using "global" to increase variables and objects scope, the new design will solve the scope issues.
Another thing to note, Sporter v2 will be much easier to extend and work with than Sporter v1 was.

Current Development Build: Alpha 2.0
Current Stable Build: Not Available

Sporter v2 is released with the MIT license so please do fork it and contribute :)


The new design
PHP:
##### STRUCTURE #####
robots.txt
.htaccess
index.php

Application\

Application\bootstrap.php


Application\Config\


Application\Controllers\
Application\Controllers\Errors\


Application\Models\


Application\Views\
Application\Views\Errors\
Application\Views\Languages\


Application\Logs\
Application\Logs\{{YYYY-MM-DD}}.php >> {{YYYY-MM-DD-hh-mm: $e}}


Application\Bootstrap\

Application\Bootstrap\Core\

Application\Bootstrap\Database\

Application\Bootstrap\Helpers\

Application\Bootstrap\Libraries\


Application\Vendor\




##### ORDER #####
index.php -> Application\bootstrap.php
 
Custom Title Activated
Loyal Member
Joined
Nov 14, 2008
Messages
1,025
Reaction score
641
Re: [ALPHA] Sporter Framework v2

tbh you're wasting your time
 
Supreme Arcanarch
Joined
Apr 1, 2012
Messages
946
Reaction score
329
Re: [ALPHA] Sporter Framework v2

too bad ms is dead and nobody is going to use it (except for maybe you)
 
may web.very maple.pls.
Loyal Member
Joined
Aug 12, 2009
Messages
1,810
Reaction score
606
Re: [ALPHA] Sporter Framework v2

Location: Sporter/application/bootstrap/core/router.class.php
Summary: In your handle_route function, you are repeating some codes in other if statements, just move it outside. Repetitive.
Question: the get_routes function has an argument $config and "$this->handle_route($match);" is calling $match, but the $match variable doesn't exist in that function nor class anywhere?
Changes:
Below:
PHP:
protected $route;
Add:
PHP:
private static $errorMSG = ['errors/errors', 'ErrorHandler', 'not_found'];
private $error = false;
Replace (twice from line 36-39 and 44-47):
PHP:
$lolwat = ['errors/errors', 'ErrorHandler', 'not_found'];
				$controller_class = $lolwat[0];
				$controller_name = $lolwat[1];
				$action = $lolwat[2];
With:
PHP:
 $error = true;
Above:
PHP:
include CONTROLLERPATH.$controller_class.CONTROLLERFIX.EXT;
Add:
PHP:
if($error) {
			$controller_class = self::$errorMSG[0];
			$controller_name = self::$errorMSG[1];
			$action = self::$errorMSG[2];
//Add $error=false; if the $error variable doesn't reset or an error comes up
		}

Also remove a bunch of functions in your classes that are empty, no use for them. Besides that I can't help you anymore, the project is literally like 2-3 frameworks(if you include the DB framework), I'm not optimizing a framework. Literally 95% of the github is framework relations and framework classes. Hope this helps though.
 
Joined
Sep 8, 2011
Messages
822
Reaction score
129
Re: [ALPHA] Sporter Framework v2

Location: Sporter/application/bootstrap/core/router.class.php
Summary: In your handle_route function, you are repeating some codes in other if statements, just move it outside. Repetitive.
Question: the get_routes function has an argument $config and "$this->handle_route($match);" is calling $match, but the $match variable doesn't exist in that function nor class anywhere?
Changes:
Below:
PHP:
protected $route;
Add:
PHP:
private static $errorMSG = ['errors/errors', 'ErrorHandler', 'not_found'];
private $error = false;
Replace (twice from line 36-39 and 44-47):
PHP:
$lolwat = ['errors/errors', 'ErrorHandler', 'not_found'];
                $controller_class = $lolwat[0];
                $controller_name = $lolwat[1];
                $action = $lolwat[2];
With:
PHP:
 $error = true;
Above:
PHP:
include CONTROLLERPATH.$controller_class.CONTROLLERFIX.EXT;
Add:
PHP:
if($error) {
            $controller_class = self::$errorMSG[0];
            $controller_name = self::$errorMSG[1];
            $action = self::$errorMSG[2];
//Add $error=false; if the $error variable doesn't reset or an error comes up
        }

Also remove a bunch of functions in your classes that are empty, no use for them. Besides that I can't help you anymore, the project is literally like 2-3 frameworks(if you include the DB framework), I'm not optimizing a framework. Literally 95% of the github is framework relations and framework classes. Hope this helps though.

Yeah, I decided to use external libraries for components that my current level is insufficient to write on my own, although I could've tried but then again as Greenelf said, it would be reinventing the wheel..

Regarding the question you asked about the variable.
Since the constructor calls get_routes function, and the get_routes function directly includes the router.php from configuration dir which does have the $match variable, then calls $this->handle_route($match); from get_routes with the variable that was set inside the included file one line before it, within the scope of the function, I think this variable does exists and it works, otherwise I'd see an error because the ENVIRONMENT is set to development and there's no php error/exception handling at the moment.

I can't seem to find the empty functions you were talking about unless you meant for the functions in *_controller.php which are supposed to be empty at the moment, these are the "actions" of the controller, each function will set it's own view, models and logic for it's page, i.e. class News function index is route /news
News->test is route /news/test, etc..

I have fixed the repetitive code, thank you very much for that! I really appreciate it :)
 
Joined
Jul 12, 2011
Messages
1,229
Reaction score
475
Re: [ALPHA] Sporter Framework v2

I don't understand this project anymore. If you've switched to MVC & OOP, and you are using released components on Github, what exactly are you doing other than building some additional configuration and views? How is this any different from a framework like Slim? Why not just use Slim? What you are doing is now trivial, because you are no longer against using tried and true libraries. Also, if you insist on building your own "micro framework" you should be using Symfony components, because those are considered to be the standard.
 
Joined
Sep 8, 2011
Messages
822
Reaction score
129
Re: [ALPHA] Sporter Framework v2

I don't understand this project anymore. If you've switched to MVC & OOP, and you are using released components on Github, what exactly are you doing other than building some additional configuration and views? How is this any different from a framework like Slim? Why not just use Slim? What you are doing is now trivial, because you are no longer against using tried and true libraries. Also, if you insist on building your own "micro framework" you should be using Symfony components, because those are considered to be the standard.

I am not using public libraries for each and every thing there, I used it for the complex stuff that I can't possibly do on my own in a good way, and actually because of you, you told me to not reinvent the wheel so I use existing components to not rewrite my own, which will be worse than the ones I'm using.
By doing this project, I get the chance to go underneath the surface and see how everything works, learn more than what I could learn by using a different framework.
Using Symfony components? No, why? Because all the other frameworks use it. I want to have something different here.

Although using these third party components shortens the development time and make everything easier for me, it still doesn't do everything for me, I still need to write countless of libraries myself, lots of features and assemble everything together in a good way that will allow people to maintain it and extend it easily, so no - I'm not "building some additional configuration and views".
Let me guess, you thought I'll be using all the procedural code that is available in the MapleStory community for all the features or perhaps ripp your MapleBit/Cype's functions? No, if I were to do so then there would be no "work" to do here at all, everything else regarding the framework would be irrelevant in that case. I'll be writing every function from scratch in OOP.
 
Joined
Sep 8, 2011
Messages
822
Reaction score
129
Re: [ALPHA] Sporter Framework v2

New class have been added, called Sporter.
This class will be responsible for providing external functionalities to the Controllers and Views.
All the necessary tools for building your application safely and efficiently will be in that class.

Sporter Alpha v2.0.0.1 is already faster, more efficient and even smaller in size than Alpha v1.5 by more than three (3) times(!), this of course excludes the git and static folders that may add some weight there by up to 1mb.

Even if I don't post updates/push new commits, it doesn't mean I stopped working on it. I continue to work on this fascinating project and hopefully the end product will be amazing and useful for many Maplers ;)
 
Supreme Arcanarch
Joined
Apr 1, 2012
Messages
946
Reaction score
329
Re: [ALPHA] Sporter Framework v2

I am not using public libraries for each and every thing there, I used it for the complex stuff that I can't possibly do on my own in a good way, and actually because of you, you told me to not reinvent the wheel so I use existing components to not rewrite my own, which will be worse than the ones I'm using.
By doing this project, I get the chance to go underneath the surface and see how everything works, learn more than what I could learn by using a different framework.
Using Symfony components? No, why? Because all the other frameworks use it. I want to have something different here.

Although using these third party components shortens the development time and make everything easier for me, it still doesn't do everything for me, I still need to write countless of libraries myself, lots of features and assemble everything together in a good way that will allow people to maintain it and extend it easily, so no - I'm not "building some additional configuration and views".
Let me guess, you thought I'll be using all the procedural code that is available in the MapleStory community for all the features or perhaps ripp your MapleBit/Cype's functions? No, if I were to do so then there would be no "work" to do here at all, everything else regarding the framework would be irrelevant in that case. I'll be writing every function from scratch in OOP.

"different"
just because its different doesnt mean people will use it neither does it make it better
 
Joined
Sep 8, 2011
Messages
822
Reaction score
129
Re: [ALPHA] Sporter Framework v2

"different"
just because its different doesnt mean people will use it neither does it make it better
Have you even bothered to read the previous comments or the first post? I think not.
I never said it will be better than the other Frameworks, I'm still a newbie and even the best programmer in RaGEZONE can't make a framework that could compete with the popular frameworks, these are made by people who regularly work on enterprise applications, in case you forgot I'm just a beginner.

Why would anyone use this? I already explained why, this will be more suited for MapleStory and also will give you a complete solution, you wont even need to deal with tech stuff like programming, it will have everything you want. Also changing templates will be so easy that a 12years old could do it without previous knowledge/experience in coding of any sort.

I also plan to make extensions and plugins library for this, to allow people to install new features easily without the need to manually edit files (much like vBulletin has, same can be done for templating), taking MapleStory websites 10 steps ahead. But that's too early to even talk about this.



Rolled a small update
New view container has been added, still need to isolate it and make some checks (not empty, whether key/value exists, etc).
Loading views is now available as follows
PHP:
    $this->load()->view([
        'name' => 'file_name',
        'ext'  => 'extension',
        'path' => 'path_from_views'
    ], $data);
// REQUIRED 'name' - that is the name of the file you want to load, if file doesn't exist it will load welcome.php
// optional 'ext'  - file extension, default {ENV}EXT=php,
// optional 'path' - inner path to file from views directory, i.e. 'errors/' will look the file at 'application/views/errors/', default {ENV}VIEWPATH=application/views/

TODO
PHP:
    $this->load()->template([
        optional 'above_header' => 'file_name',
        optional 'header'       => 'file_name',
        optional 'header_sub'   => 'file_name',
        optional 'below_header' => 'file_name',
        optional 'above_body'   => 'file_name',
        REQUIRED 'body'         => 'file_name',
        optional 'below_body'   => 'file_name',
        optional 'footer'       => 'file_name',
    ], $data);
 
Joined
Sep 8, 2011
Messages
822
Reaction score
129
Re: [ALPHA] Sporter Framework v2

Another small update
I just wrote very basic templating function, perhaps I'll even make a full templating engine from it (if else, foreach statements, etc).

PHP:
        $this->load()->template([
            'tpl_name' => 'default',
            'view_name' => 'welcome'
        ], $data);

In the template file, add
PHP:
{{ @ Content }}
wherever you want the view file to be loaded and it will.
 
Joined
Sep 8, 2011
Messages
822
Reaction score
129
Re: [ALPHA] Sporter Framework v2

New release, Alpha 2.0.0.2 is now available as the most stable build.
Stable Build:
GitHub:
Build Size: 39.6kb
 
Joined
Sep 8, 2011
Messages
822
Reaction score
129
Re: [ALPHA] Sporter Framework v2

Pushed a small update for the routes and error handlers, some small optimizations (mainly changed array_key_exists() to isset() because it's faster).
If and of your controllers throws an exception, when accessing it, it will display the router's default 0x00 operation code error, I will change this later to a more specific operation method like
PHP:
ROUTER_NO_FILE_OPERATION(),
ROUTER_NO_CONTROLLER_OPERATION(),
ROUTER_NO_METHOD_OPERATION()
 
Joined
Sep 8, 2011
Messages
822
Reaction score
129
Re: [ALPHA] Sporter Framework v2

Currently working on yet another rewrite, I'm pretty sure this one is somewhat final as I already got some understanding of OOP.
The new version will follow the PSR standards (hopefully, this depends on how much information I could absorb about this in such a short time), Singleton and will have an autoloading (either Composer, SPL or self made).
Loading views and templates (and also PHP plugins) will be stored and retrieved from Database and written to the disk as a cache. Still reading about this and it's really interesting (The way WordPress and vBulletin does it).
 
Joined
Jul 12, 2011
Messages
1,229
Reaction score
475
Re: [ALPHA] Sporter Framework v2

Currently working on yet another rewrite, I'm pretty sure this one is somewhat final as I already got some understanding of OOP.
The new version will follow the PSR standards (hopefully, this depends on how much information I could absorb about this in such a short time), Singleton and will have an autoloading (either Composer, SPL or self made).
Loading views and templates (and also PHP plugins) will be stored and retrieved from Database and written to the disk as a cache. Still reading about this and it's really interesting (The way WordPress and vBulletin does it).

Use composer. Do not make your own...please.
 
Joined
Sep 8, 2011
Messages
822
Reaction score
129
Re: [ALPHA] Sporter Framework v2

Use composer. Do not make your own...please.

I've yet to look much into Composer, once I do I'll determine whether I use it or use the alternatives.
This will most likely depend on ease-of-use for complete beginners, convenience and flexibility.
I'm looking into working with namespaces and interfaces too, this may be a plus.

Also I'm currently thinking whether to take this development down and develop it privately or leave as is (open source). I've yet to receive any feedback on my code, ultimately this makes the quality of the code pretty bad because no one points out what I'm doing wrong so I can't really improve, which is a shame.
 
Joined
Sep 8, 2011
Messages
822
Reaction score
129
Re: [ALPHA] Sporter Framework v2

@greenelfx
I don't see how composer could contribute to this project, it will just make things more complicated for beginners.
I finally understand a bit about namespaces, at first I thought it does something else but now I understand it.

Here's a very minimal prototype, been spending most of the time on organizing it, thinking of the concept and planning how I'll put it down in code.
 
Back
Top