I want to program the Euler-Lagrange equations for continuous systems. But in this formulation I have to compute the derivative of the Lagrangian with respect to all the derivatives of the generalized coordinate. $$\partial_i\left(\dfrac{\partial \mathcal{L}}{\partial (\partial_i\phi) } \right) = \dfrac{\partial \mathcal L}{\partial \phi }$$ For example, for a field $\phi=\phi(x,t)$ $$\dfrac{\partial }{\partial t}\dfrac{\partial \mathcal L}{\partial \dot\phi}+\dfrac{\partial }{\partial x}\dfrac{\partial \mathcal L}{\partial \phi'}=\dfrac{\partial\mathcal L}{\partial \phi}$$ Where $\dot\phi=\dfrac{\partial\phi}{\partial t }$ and $\phi'=\dfrac{\partial \phi}{\partial x }$
I have tried with something like this
D[L, D[ϕ, t]] + D[L, D[ϕ, x]] = D[L,ϕ]
But of course, it returns an error because of the variable with respect the derivative is taken.