I/O operations with PHP/MySQL - I'm stuck
Is there any reason why you can't use PHP to save it directly as a JSON file rather than on the database?
Read full answer below ↓Question
Hello and thank you for GrapesJS. It's awesome. I do have a question that I haven't been able to find an answer to. I'm using PHP/Yii and MySQL db.
Your example for external storage config:
> storageManager: {
type: 'remote',
urlStore: 'http://endpoint/store-template/some-id-123',
urlLoad: 'http://endpoint/load-template/some-id-123',
}
> {
// `gjs-` is the id prefix
'gjs-components': [{ tagName: 'div', ... }, {...}, ...],
'gjs-style': [{...}, {...}, ...],
}
My problem is that I'm trying to get the HTML to JSON conversion formatted properly before saving to the db record so we can pull it up again from urlLoad. I can't find ANY clear examples of how to do this from PHP. I could try using the Firestore plugin and save myself the trouble, but I thought I'd ask if there were any clear examples of how to do I/O operations with PHP/MySQL.
Maybe using HTML-5 html2json (http://masterminds.github.io/html5-php/) would help? Or does GrapesJS automatically do the HTML to JSON/DOM conversion on the fly? It's not clear to me from the docs.Answers (3)
Is there any reason why you can't use PHP to save it directly as a JSON file rather than on the database?
I probably could, but we need to saved to DB. I'm OK, a developer figured it out for me, but it would be great to have some more detailed code examples for use with php/mySQL. Your docs are great, but this would be a nice addition to your docs section.
My problem is that I'm trying to get the HTML to JSON conversion formatted properly
GrapesJS, by default, generates 4 types of data: HTML, CSS, Components (JSON from HTML), Styles (JSON from CSS) So you shouldn't do any kind of conversion... it's explained here https://grapesjs.com/docs/modules/Storage.html#store-and-load-templates
Related Questions and Answers
Continue research with similar issue discussions.
Issue #3589
Autoload storage is not working on page refresh
Hi, firstly I want to say that this project is awesome, thank you! I used code from GrapeJS Demo example, and added there save and load dat...
Issue #2929
Keep getting CORS when using fake endpoint for remote storage
Hi everyone! I'm using grapesjs with vuejs and I'm struggling with CORS. I created my fake endpoint with beeceptor and I have the code belo...
Issue #2894
[Question]: How Do I Hide / Disable Dropzone in AM Modal
Hello, I've been reviewing the documentation and this link, trying to find the right configuration setting to disable the dropzone in the A...
Issue #1985
[BUG] Autosave with remote storage doesn't send network requests
OS: Windows 10 Browser: Chrome 73 GrapesJS version: 0.14.57 I have remote storage configured using this call to grapesjs.init(): While I se...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.
Browse free plugins →Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.
Browse premium plugins →Related tutorials
In-depth guides on the same topic.
Tutorial
Find the Right GrapesJS Plugin in Seconds: Smarter Discovery Is Live
We're shipping a set of discovery upgrades. New label filters, a proper compatibility switch for GrapesJS vs Studio, one-click and a smarter sort bar.
Tutorial
Preset DevFuture 2.0 — New Update Released
Preset continues evolving as a clean, production-ready starting point for building visual editors powered by GrapesJS
Tutorial
AutographJS - Signature Solution for Modern Web Editors
The Problem: Signature Capture Is Still Harder Than It Should Be
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.