I am currently playing with Slim 4 for the main framework and I am starting to migrate one of our great applications.
Is the Slim 4 a good choice for really large applications (with many user interfaces and REST APIs)?
I know I could divide the application into a few small services, but this will happen gradually in the future.
I opted for Slim 4 (after trying Yii3, Laravel and Symfony) for its extreme customization and since our application has a lot of custom components, I think Slim 4 is very easy to customize compared to other frameworks.
In this way, by developing the application components ourselves, we are better able to adapt the application to our needs and we know exactly how it is made.
Any advice for a newbie approaching Slim?
I work professionally for a company, only with Symfony mostly with PIMs (PIMCORE, AKENEO, Commerce Tools) so I am actually the one who might have a quite good perspective. If I work as a freelancer for my own client, if would have to recommend a technology to “make his dreams come true” I will never speak about this huge inert cow. Symfony provides you with everything you need for an enterprise application by default, but … only if you don’t mind take your family for a vacation driving a huge trans-american truck instead of a nice family van.
I prefer to make my own choices especially well supported by PSRs. So if you need a light and flexible structure, full control, freedom of choice and you still feel like a fun to make your code, there is nothing made in Symfony that can not be made with Slim 4.
Maybe It’ll take more time, but certainty your project will be lighter, faster, easier to manage, more flexible and adaptable for both modern and established programming conventions.
Thanks @tj_gumis for answering.
My application is heavy customized, because use Cloud Spanner as database, Cloud Logger for logging, Cloud Tasks for background tasks (all products of Google Cloud), so there is no framework already shipped with this features, so using Slim is probably simpler to maintain in the long run.
@LordLele please do not hesitate to share with us your progress with Slim 4 and experience with Google Cloud. There is a lot of helpful people right here so you won’t have to invent the wheel once again.
For now I’ve started from @odan slim 4 skeleton but already customized the Session and the CSRF to use Redis and the LoggerFactory to inject a Cloud Logging handler.
Do you have any list of hints or common pitfalls in using Slim4?
I’m still learning the whole DI concept and I’m trying to do all in “the right way”.
In my blog (and also now on Youtube) I try to explain the DI container concepts from the ground up.
The most important topics are “SOLID” and how to “compose” classes to make use of the outwriting features. Learn about dependency injection. Prefer “composition over inheritance”. Use final classes by default. Use the constructor to declare all class dependencies. Declare classes within the constructor and try to avoid declaring primitive data types (like array, int, string etc.)
Here are some links:
Many years (decades?) ago, I did some minor PHP scripting on webforms and server-side handling for simple things e.g. email, signup, etc. Just a few years ago, I was tasked with similar web functionality and picked-up PHP again and decided to use Slim v3 for API dev. I’ve done many API over the years e.g. REST, SOAP, Corba, etc mainly with Java and JS, so I have some foundation. Anyways, Slim 3 PHP was a breeze to implement and map routes and handling. I’m on a new side project and am now checking out Slim 4. It’s definitely more complicated than v3, but I’m hoping all that extra can be avoided if I don’t need to use it. Let’s keep in-touch and see how it goes, ok?
@robm99x sure 110%!!!
Feel free to contact me anytime you want to ask or share something