Improvements
If you'd like to show a really useful full complicated example of hello world based on symfony, then I think you should add some more things to this:
- Service layer. Of course, use DI. In this case it will be short and simple, but in big apps you would anyway prefer to keep logics such as getting data from repository in service rather then in controller.
- Document responses, operate with response and request entities, probably use smth like protobuf or one of the other popular tools, which will then be converted to JsonResponse
- Cover service, repository, controller with tests, use fixtures
After these things it will look more like a complete hello world in modern world and will be more about php side rather then JS :)
P.S. Sorry, don't have access to comment on habrahabr :)
Service layer. Of course, use DI. In this case it will be short and simple, but in big apps you would anyway prefer to keep logics such as getting data from repository in service rather then in controller.
What service layer could be in this case? There's no buisness logic at all here :)
Document responses, operate with response and request entities, probably use smth like protobuf or one of the other popular tools, which will then be converted to JsonResponse
Great idea :)
Cover service, repository, controller with tests, use fixtures
I should've done it but I spent too much time for the article, so... It seems I'm just too lazy.
https://habrahabr.ru/users/uitrix/ - is it your account?
I can give you an invite to habr
What service layer could be in this case? There's no buisness logic at all here :)
Still a lot of teams have an agreement to not operate with repositories in controllers too. It restricts one to modify the behaviour if some kind of business logics will be required in there since you should not place it in repo. Also, since it is an advanced example of hello world it is nice to use service in it to make it more advanced :)
https://habrahabr.ru/users/uitrix/ - is it your account?
Yup, it is. Wow, I'd be very thankful :)
Yup, it is. Wow, I'd be very thankful :)
done
Thanks a lot! :)