Large project example

Hi all! I searching for large (>1000 files, >50 database tables) project. Currently i do growing application and i have problem with too many controllers / forms / others in one folder. Multimodule application helped but not as good as SF bundles. Module isolation is too strong for me. Can you show / link yours large projects?



2.9k

I have problem with too many controllers / forms / others in one folder.

  • Why is it causing you issues?
  • Is this because of your naming convention or just there's too many files?
  • Are there multiple controllers that can be combined into 1 controller? Have you gone too granular?

Main problem is too many files in one folder and too many children of one parent. I have diffrent functionality in diffrent controllers, but they are still in one folder. The same problem occurs with forms / repositories / models / etc. If i work with one functionality others reducre readability. Usually one controller have 4 - 6 methods and about 200 lines. I trying be compatible with PHPMD but NumberOfChildren Rule kill me.

I guess there is no really possbility to change it, you could try somehow to make more abstract classes, move some same functionallity to some service etc things, i guess ong bigger project there will always be some big amount of files or code.

But is this a performance issue, or a code management one?

If you use opcache then code managment only.

But is this a performance issue, or a code management one?

I have problem with code management and architecture quality. Performance is ok

I guess there is no really possbility to change it, you could try somehow to make more abstract classes, move some same functionallity to some service etc things, i guess ong bigger project there will always be some big amount of files or code.

I have good experience with "modules" from SF1 and "bundles" from SF2/3. They are good way to separate functionality. I searching for some equivalent.

I guess there is no really possbility to change it, you could try somehow to make more abstract classes, move some same functionallity to some service etc things, i guess ong bigger project there will always be some big amount of files or code.

I have good experience with "modules" from SF1 and "bundles" from SF2/3. They are good way to separate functionality. I searching for some equivalent.

In my understanding, the bundles of SF introduce an extra overhead, thus impacting performance. Phalcon is streamlined for performance first, and only then concerns itself with dev-convenience.

As suggested, try refactoring your shared code into abstract classes or services. For example, when using vendor APIs, we use global services for them. Another thing I found useful is to have common DB models and autoload them into every module.

Then modules in phalcon can be exactly like bundles from SF 2/3

Then modules in phalcon can be exactly like bundles from SF 2/3

There are similarities, but as @pwoszczyk stated, SF has more interoperability between bundles, and is also more versatile (public assets, inheritance, parallel bundles). All at the cost of performance ofc.

edited Mar '17

I guess there is no really possbility to change it, you could try somehow to make more abstract classes, move some same functionallity to some service etc things, i guess ong bigger project there will always be some big amount of files or code.

I have good experience with "modules" from SF1 and "bundles" from SF2/3. They are good way to separate functionality. I searching for some equivalent.

In my understanding, the bundles of SF introduce an extra overhead, thus impacting performance. Phalcon is streamlined for performance first, and only then concerns itself with dev-convenience.

As suggested, try refactoring your shared code into abstract classes or services. For example, when using vendor APIs, we use global services for them. Another thing I found useful is to have common DB models and autoload them into every module.

Thanks for good advices. I done many things what you describes. I have common model and common services (and per module). Still i have to many code in one module. I divide functionality into tree modules (api, backend, frontend). I can not make smaller modules for the reasons you specify. In need to share assets, dispath betwen controllers, etc. I dont whant globalize all things.

Maybe exist good example of large project and somebody solve scalability problem in Phalcon.



34.7k

You can take look a project phanbook at http://github.com/phanbook/phanbook

You can take look a project phanbook at http://github.com/phanbook/phanbook

Thank for example!

I found also Yona CMS: https://github.com/oleksandr-torosh/yona-cms

edited Apr '17

In my humble opinion, the default approach for directory structure in Phalcon is not too good for large projects. But it's a good thing, because probably most of the projects are small, and not need overcomplicated folder structure and other rules that apply to big projects.

It happens im creating mostly large systems like consiting 100+ tables in DB, with thousands of uploaded files, tens of admins concurrently working in the system + houndred of other sessions crawling the front-end.

Fortunately Phalcon allows you to create your own place for every model or view, it not need to be all in one folder, and that's what i did.

You just getting dispatcher out of dependency injector and then you have methods to manage those things like setDefaultController, setDefaultAction, setControllerName, setActionName, setParams. The same thing goes with Router and other components - just experiment with that.

I personally created somethig like boilerplate/backend admin panel generator together with components like jquery, bootstrap to accelerate my work, where all folder structure and few other things are different than default Phalcon settings.