Skip to content
Grav 2.0 is officially stable. Read the announcement →
General

Headless and customize via API. Is this possible?

Solved by pamtbaau View solution

Started by Marty Sa 4 years ago · 5 replies · 675 views
4 years ago

I'm looking to use Grav as headless completely with interaction through the API. Is it possible to build a wrapper applicaiton that would interact with multiple Grav instances in an API only way to setup websites and modify them too. What level of customization can I do on the sites via the API?

4 years ago

@Marty, This question is too broad to answer with a simple yes/no...

  • Did you search the forum? There are about 6 other posts containing "headless".
  • Please share what research you have done and which limitations you see.
last edited 12/29/21 by pamtbaau
4 years ago

I did and I still couldn't gather much. To rephrase my question and simplify a bit, lets ignore headless. How much of a GRAV website can I manipulate via API? By API, I mean an alternative programmatic interface instead of Adminpanel. I came across this https://learn.getgrav.org/16/api, but I dont think its a typical REST API/endpoint.

last edited 12/29/21 by Marty Sa
4 years ago

@Marty, There is no REST API for Grav. The API chapter in the docs is a overview of Grav's classes and their methods.

  • Admin is a nothing but a (optional) Grav plugin providing a web frontend which submits request to the Grav websites it has been added to. This means anything Admin can, your app can (and more) using the framework provided by Grav, and/or plain PHP.
  • Grav's multi-site functionality allows multiple sites to run on a single Grav installation.
4 years ago

Thanks for explaining it. Can you elaborate more on the framework and/or plain PHP part? The way I see it, if my app manipulates the flat file contents, that should be enough. Is there another way to do it?

4 years ago Solution

@Marty, I've used the term "framework" loosely as the library of classes provided by Grav. Most of these classes are documented in the API chapter. It's nothing but a layer on top of plain PHP, hence the "and/or".

Everything in Grav (configs, pages) is stored in flat files, which can be manipulated by any app - with or without using Grav's classes. Admin is optional and isn't needed at all. You can manage the entire website using vi, vscode, or any other editor.

Suggested topics

Topic Participants Replies Views Activity
General · by Hanns Mattes, 17 hours ago
1 22 10 hours ago
General · by Andy Miller, 10 hours ago
0 23 10 hours ago
General · by Jerry Hunt, 5 days ago
2 144 2 days ago
General · by pamtbaau, 2 days ago
1 95 2 days ago
General · by Andy Miller, 2 days ago
0 79 2 days ago