M
M
maxonlinux2022-03-13 03:49:11
CMS
maxonlinux, 2022-03-13 03:49:11

How to interact with headless CMS?

Hello. I recently started studying web devs, I have a base of html, css and js, I remembered something from my old beginnings. Of course, I tried all sorts of wordpresses and all sorts of different cms that don’t work for me. Interested in the headless CMS concept, installed Strapi and now I can't figure out how to connect it to the front? I create content in the admin panel, but what should I do with it? Where is it stored, how to display it on a PHP site? I read the manual on the site, but did not understand anything. Some rest api, frameworks (I heard that there are all sorts of Laravel, vue and others, but so far I have no idea why they are needed and how to do without them). Tell me how the front interacts with these "headless" admins?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Nesterov, 2022-03-13
@AlexNest

I installed Strapi and now I can't figure out how to tie it to the front?

Where is it stored, how to display it on a PHP site?

Moment number 1: Since when has PHP become a front? The fact that you put a piece of html markup in [filename].php does not make the language a frontend.
Moment number 2: Let's say you still understand the difference between the server side of the site and the client side and really want to transfer data first to PHP. In this case, the question arises - what for? All the logic (well, or at least the main one) related to data processing is already implemented in Strapi, from the "other side" you need to "stupidly" send and receive data (very simplified, but at the moment it doesn't matter). And in 2022, JS spinning in the browser is enough for this.
(No, of course, there are complex services that transfer data between different "independent" servers (see microservices), but something tells me that this is not your case)
Some rest api, frameworks

Well, read about these "some". At a minimum, the rest api is the most specific thing.
To put it as simply as possible, it looks like this:
  1. The client part (js in the browser / a full-fledged application on a PC / smartphone, or another server, as I wrote above ) sends a get / post / ... request to a specific address.
  2. The server part accepts this request, highlights the data that came in the request body (which is not always there)
  3. The server part does some magic (fetching data from the database, including based on the data received from the client, or somehow processes them).
  4. The server part sends ready-made data in one of the formats (often json, but sometimes there may be others, like xml).
  5. The client side receives them and displays them (with or without some kind of logic applied)

This is if we consider the most primitive option. In fact, this process involves more layers by type of authorization.

N
no_one_safe, 2022-03-13
@no_one_safe

Habr

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question