ray-ang / basicphp

BasicPHP - A frameworkless class library for developing web applications and services
MIT License
20 stars 7 forks source link

MVC-less version? #2

Closed aolko closed 4 years ago

aolko commented 5 years ago

Can you provide an MVC-less branch for people who prefer MV* model or none at all?

ray-ang commented 5 years ago

Hi @aolko . The current release uses MVC approach, but it is not MVC-dependent. The major files are index.php, config.php, functions.php and routes.php. The models and controllers folders were just autoloaded to adhere to MVC, with the views folder containing included html scripts in php files. Do you mean a branch without controller files, and just include php files based on the path with an autoloaded models folder?

aolko commented 5 years ago

Do you mean a branch without controller files, and just include php files based on the path with an autoloaded models folder?

basically that, lighter if possible

ray-ang commented 5 years ago

I have explored that option before and realized that for better code organization a class-based approach is better then file-based. The framework has the same auto routing capability as Codeigniter (i.e. /class/method in the url) using just 1 controller class rather than separate the methods under 1 class into individual php scripts.

aolko commented 5 years ago

Can you redo the router to match sinatra style? Or similar to a cross of macaw and klein.php.

As for classes, at least redo them as statics.

ray-ang commented 5 years ago

Macaw and klein rely on composer. BasicPHP is a very simple framework that does not need composer. It does, however, in addition to automatic routing, have the route_class( ) function for endpoint routing to create REST API's, just like any other PHP framework.

The route_class( ) function was designed to instantiate an object, that is why the controller classes are not static.

aolko commented 5 years ago

I don't see any heavy reliance here, the point is the sinatra-like syntax, not composer.

ray-ang commented 5 years ago

I mean to use Macaw or klein, you need composer. The endpoint routing syntax may be same as other PHP frameworks as well.

aolko commented 5 years ago

I mean to use Macaw or klein, you need composer

True, but still not the point

The endpoint routing syntax may be same as other PHP frameworks as well.

Nah, sinatra-like is better and way more readable

ray-ang commented 5 years ago

Can you make a pull request, so I would be able to check your code and possibly integrate?

aolko commented 5 years ago

that will basically mean writing that thing from scratch, so, in case if you want to see taped macaw to it, maybe?

ray-ang commented 5 years ago

I guess I will have to leave the routing as is for now. It's just 1 function for the endpoint routing with the syntax like the other frameworks.