i have a small SAS ERP that was written some years ago using PHP.
At that time, it didn't used any framework, but the code isn't a mess as i will explain more detailed in the following lines.
Nowadays, the project grow and I’m now working with 3 more programmers.
Often, they ask to me why we don’t migrate to a framework such Laravel.
Although I'd love trying Laravel, I’m a small business and i don't have time/money to stop and spend a whole year building everything from scratch. I need to live and pay the bills.
So, I've read a lot about this matter, and I decided that doing a refactoring is the best way to do it.
Also, I'm not so sure that a framework will make things easy.
Business goals are:
Make the code easier to new hired programmers
I must separate the "view", because:
I want to release different versions of this product (using the same code), but under different brands and websites at the minimum cost (just changing view)
Release different versions to fit mobile/tablet.
Make different types of this product, seeling packages as if it were plugins.
Develop custom packages for some costumers (like plugins/addon's that they can buy to put on the main application).
Code goals:
Introduce best pratices, standards for everyone
Try to build my own MVC structure
Improve validation of data/forms (today they are mixed in both ajax and classes)
Create automated testing rotines, to quality assurance.
My actual structure project:
class\
extra\
hd\
logs\
public_html\
public_html\includes\
public_html\css|js|images\
class\
There are three types of classes.
They are all “autoloaded” with something similar with PSR-0, but I don’t use namespaces.
1. class.Something.php
Connects to Database using specific methods. I.e: Costumer-list();
It uses “class.Db.php”, that it’s an abstraction of mysqli on every method.
2. class.SomethingProc.php
Do things that “join” things that come from “class.Something.php”. Like IF/ELSE, math operations.
3. class.SomethingHTML.php
The classes with “HTML” suffix implements only static methods and HTML code only.
A real life example:
All the programmers need to use $cSomething ($c to class) and $arrSomething (to array).
Costumer.php (view)
<?php
$cCosumter = new Costumer();
$arrCostumer = $cCostumer->list();
echo CostumerHTML::table($arrCostumer);
?>
Extra\
Store 3rdparty projects/classes from others, such MPDF, PHPMailer, etc.
Hd\
Store user’s fies outsite wwwroot dir.
Logs\
Store phplogs and the system itself logs
(We have a static Log::error() method, that we put in every method of every class)
Public_html\
Stores the files that people use.
Public_html\includes\
Store the main “config.php” file and all files that do “ajax things”
ajax.Costumer.php, for example.
Help is needed ;)
So, as you can see we have some standards, and also for database things.
But i want to write a manual of our rules. Something that i can give to any new programmer at my companie and he can go on.
This is not totally a mess, but It could be better seeing the new practices.
What could I do to separate this as MVC, to have multiple VIEW’s.
Could you gimme some tips considering my goals? Keep im mind the different products/custom things for specific costumers without breaking the main application.
URL for tutorials, books, etc. It would be nice.
Thanks!