API: Link pages to API counterparts
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 30/100
Direzione di ricerca
Inizia tracciando le funzioni go esistenti dell’endpoint API, le funzioni go/do della pagina e il flusso di DocumentBinder descritti nell’issue. Definisci come un attributo AutoApiPage associa una pagina a un endpoint API e come vengono selezionate le funzioni do POST o PUT. Il lavoro è completato quando dati API equivalenti possono essere associati alle pagine consentendo al contempo un’ulteriore manipolazione delle pagine e la gestione dei moduli.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- PHP
- Stelle
- 26
- Fork
- 6
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di phpgt/WebEngine
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 50/100
-
Docs: missing pieces Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
-
question
-
enhancement
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
Tutte le issue di phpgt/WebEngine
Issue simili
-
[Chore] Keep one viget-block-generator skill and replicate it, instead of four tracked copies Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
hector-jewell/food-delivery-system-for-restaurant-using-php#1311 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
Sylius/SyliusGridBundle#501 ·