API: Link pages to API counterparts
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 30/100
Línea de trabajo
Comienza rastreando las funciones go existentes del endpoint de API, las funciones go/do de página y el flujo de DocumentBinder descritos en el issue. Define cómo un atributo AutoApiPage asigna una página a un endpoint de API y cómo se seleccionan las funciones do de POST o PUT. Se considera terminado cuando los datos de API equivalentes pueden enlazarse a las páginas, permitiendo al mismo tiempo manipulación adicional de las páginas y gestión de formularios.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
A very common web development technique is to design an API first, and then link it to the "front end" via lots of slow ajax calls.
This technique can still be achieved in WebEngine, but because WebEngine is completely server-side, this can be handled automatically.
For example, the following API endpoints can be created:
api/index- index API will list countriesapi/@country-namee.g. /morocco - list cities within countryapi/@country-name/@city-namee.g. /morocco/rabat - list places within cityapi/@country-name/@city-name/@place-namee.g. /morocco/rabat/national-zoo - show details on place
Once the API endpoints are created, the application's data can be used in other applications, but what if we then wanted to provide a web interface to the data, too?
It would make sense to have the pages follow the same URL structure:
page/indexpage/@country-namepage/@country-name/@city-namepage/@country-name/@city-name/@place-name
These pages will use HTML to structure the content, with data-bind attributes to indicate where the data should be bound.
The PHP should not need to "build" the data up again, because this is already done within the API's PHP logic files. Instead, the go function could be marked with an attribute #[AutoApiPage] or something similar. The presence of this attribute will automatically grab the data that an equivalent API call would respond with, and automatically performs a bind operation to the DocumentBinder. Pages might not have the exact same URL as their API counterparts, so the API endpoint can be passed into the attribute, like #[AutoApiPage("/@country-name/@city-name") for example.
Then, if more manipulation is required to the page, this can be done in the go function as usual.
Submitting a form on a page will trigger a do function. Hooking a do function to the AutoApiPage attribute will call it as a POST request, but if there's multiple do functions on the page - one for updating, one for creating, the HTTP method can be passed in as a parameter like #[AutoApiPage(HttpMethod::PUT)]. Using type juggling, these attribute parameters should be able to be passed in any order.
- Lenguaje dominante
- PHP
- Estrellas
- 26
- Forks
- 6
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de phpgt/WebEngine
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 50/100
-
Docs: missing pieces Abierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
-
question
-
enhancement
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
Todos los issues de phpgt/WebEngine
Issues similares
-
Bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Automattic/safe-publish#594 ·
-
needs-triage Platform(Default)
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
HttpClient
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
symfony/symfony-docs#23092 ·
-
sync-en
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
-
sync-en
Dificultad 1/5 Menos de una hora Aptitud para principiantes 95/100