D
D
DarthJS2017-02-08 16:45:29
PHP
DarthJS, 2017-02-08 16:45:29

Is it worth it and why to use PHP on the front, where there is Angular?

Background:
I am a front-end developer and often worked with NodeJS on the backend, it so happened that now I am working on a project where PHP is on the backend, and the PHP team itself is developers
:) Yes, and I learn NodeJS, not PHP Bottom
line:
Bekendschiki often push PHP code to the front (yii framework), for example, to check access, if the character does not have access, then we hide the HTML section using PHP.
Now we are rewriting the project and I don't want to have php on "my" :) front :)
But the last straw was the login form, which I was offered to make static in php and they say why there is ajax.
After these moments, I sit and think, why is Angular here at all?
Please give me good advice, or something to read to me, how to be?
Help :)

Answer the question

In order to leave comments, you need to log in

10 answer(s)
S
Sergej, 2017-02-08
@sayber

All right.
The front should not have PHP at all.
For example, now I am working on a large project, where financial transactions and orders go nonstop.
Backend is an api resource (rest.site.tdl) implemented on SF3+DB(any)+DDD/CQRS/Bus+JTW.
It can receive and return data in json format.
A frontend is a completely different project (site.tdl), which is physically located in a completely different place. Implemented in Angular2 typescript.
Those. these are completely 2 different projects that communicate via api.
If you do it according to the principle - everything is in a heap (and so it will do), then the moment may well come when you need to fire everyone, hire a normal team and implement a new project.

Q
Qvarck, 2017-02-08
@Qvarck

I suspect that Angular is not needed for this project. From you, as from the front, we need layout and, for example, jQuery for other needs. Sprinkle the one who decided to use Angular here with holy water so that demons come out of it)
Or, if Angular is so necessary, let PHP developers make a backend that simply communicates with your front via API. But I don't think this is the best solution.
Now I work on the front, I have a couple of years of experience in the back end. Participated in similar projects from both sides. The approach you describe seems strange to me.
P.S. It's not true to talk about "PHP at the front". PHP in views generates pages on the server and renders them in the desired form. This is a common approach when using Yii.

V
Vladimir, 2017-02-08
@azrail_dev

Are you sure you should work on this project? If you have a normal rest api and at the same time strange attempts are being made to "hide the HTML section with PHP", it is quite realistic that you will not be able to implement what Angular gives you and yourself as a programmer of this project.

A
Alexander Aksentiev, 2017-02-08
@Sanasol

Is it worth it and why to use Angular on the front where there is PHP?
If it already works and is already ready - why is there an angular?
great frontend language straight php.
If you have a SPA, then everything should be more or less angular, this is logical.
And if your Angular works through one page, why screw up too much?

L
lem_prod, 2017-02-08
@lem_prod

I want to once again emphasize what Qvarck said, PHP is not on the front, it is used as a templating engine on the back.
And if we take that example, with a block that is not available to certain users, if it is hidden on the front side, an advanced user can access it through the console if they wish ... and in the case of PHP, from the front side this is not possible.
and knowing the functionality of yii it is quite easy to implement the same ajax validation without a front-end programmer.
So really, this team needs you more as a layout designer.

M
Max Bozhenov, 2017-02-09
@max_bozhenov

I'm a Full-stack developer myself, but I like to work with Frontend more... I started working with AngularJS (gained experience with the 1st version and after the release of the second version - scored on AngularJS), made a couple of SPA projects on AngularJS and I'll say next, AngularJS is only for SPA applications, and PHP is only as a RESTful API service (in my case, I use Laravel / Lumen and I think this is the ideal solution!)
If you want to continue working on this project, take VueJS2 (my personal IMHO, it is much more pleasant than AngularJS2, and the first version has no future and it makes no sense to start new projects on it ...). And it is well suited for SSR applications, i.e. it is not necessary to do SPA. I'm just now developing a business application on this stack (VueJS2 + Laravel).
Although... if I understood correctly and you make a game in a team, then SPA is the best choice for playing in our time. So suggest in your team to switch to a RESTful API service as a backend...

I
index0h, 2017-02-09
@index0h

Let's start from afar: PHP - PHP Hypertexp Processor.
What you call "on the front" is called rendering. This can be said to be a classic use of puff. Frameworks often contain functionality that doesn't quite fit into the SPA paradigm, like in your form example.
Such inconsistencies are resolved solely through agreements in a particular project.

D
Dmitry Shnyrev, 2017-02-16
@dmnBrest

Shame on these PHP nicknames. They just pull the blanket over themselves. If you decide to use Angular in the project, then this is a completely different architecture and backend developers need to rebuild - they should already write pure rest services and forget about views, templates and other garbage that turns into html! GENERALLY ABOUT HTML let them forget. If you still receive tasks to render something on the server, then you don’t need Angular.

A
Abdula Magomedov, 2017-02-08
@Avarskiy

No, then we'll have porridge if the project is big

M
McBernar, 2017-02-08
@McBernar

PHP is easily replaced by the same TWIG. But the essence of this will not change - it's just a markup of logic.
You either translate the entire front into JS and communicate via API, or don’t worry, because sometimes business just needs to work, and the faster / easier, the better.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question