AbayoB
-
Posts
1 -
Joined
-
Last visited
Posts posted by AbayoB
-
-
Hey you,
I am new to this forum, so I thought an introduction is at order:
I am Bart, a web developer, currently working at Abayo.
Abayo is a custom built (PHP MVC) CMS that focuses on the following aspects:- Main target group: small and medium businesses
- Customization of a website made easy
- Community system that connects users, designers, business people, etc, together.
The business is still in start-up phase, but we've come a long way.
Currently, the system is getting more complex and, because I am the only developer, the questions I have become more and more complex.
I was hoping that I could get some answers to my questions here, StackOverflow isn't getting me anywhere anymore haha.
Hope to discuss with you soon!
Happy regards,
Bart
How to create an intuitive interface for dependency management combined with code includes?
in Application Design
Posted
Heya,
I am building on a PHP CMS system that parses template files and replaces tags with content. Sometimes this content is a HTML, CSS or JS snippet, but it can also be a code include.
Most code includes use dependencies, already set in the main scope: the app class, where the start() function resides and all needed domain objects are loaded. Some of these objects are: site, url, page, etc..
The PHP scripts are included inside a different scope, so I can't access the dependencies the way I want -> from the app class.
I am thinking about Dependency Injection using a dependency container class, but because the dependency container is defined in a different scope, this object is not visible when working inside an include file.
The question that arises is: How do I keep the dependencies accessible in an intuitive way?
Code example:
The fragment object that the dependencies are passed to:
An include file would look like this:
I have the feeling this is very hard to understand without first understanding how and where the dependencies are set and injected?
Also, a variable is not standing out into the page, which seems to be what I need here for readability.
I have searched in the Laravel Framework, but they use Facades, which I think looks awesome, but is to much work to implement ATM.
Static classes that are stateful, which is what the dependency container would be, are bad practice, is it not?
Pure based on readability, this looks great:
This does not:
Are there more options to choose from?