Table of Contents
A headless CMS is getting more popularity these days because of its decoupling of the backend and the frontend. It is very easy to have a frontend of your choice and a backend of your choice. In this way you can have different technologies of your choice working behind but all together get an awesome CMS experience. Unite CMS is a very good and promising headless CMS which is based on PHP Symfony 4 framework and all the data is fetched by the GraphQL API. There is already a administration section available to manage the CMS whose frontend is made with Vue JS.
1. Clone the repository
1 |
composer create-project unite-cms/standard unitecms --stability dev |
2. Update the database
1 2 |
cd unitecms bin/console doctrine:schema:update --force |
3. Create the super user
1 |
bin/console unite:user:create |
4. Create the main organisation
1 |
bin/console unite:organization:create |
As per the present code base, there is a problem (which will be hopefully solved in the upcoming version) which will result in an error message like The class 'Gedmo\Loggable\Entity\LogEntry' was not found
and the solution to it is to add some code in the file config/packages/doctrine.yaml
1 2 3 4 5 6 7 8 |
orm: mappings: gedmo_loggable: type: annotation prefix: Gedmo\Loggable\Entity dir: "%kernel.project_dir%/vendor/gedmo/doctrine-extensions/lib/Gedmo/Loggable/Entity" alias: GedmoLoggable # (optional) it will default to the name set for the mappingmapping is_bundle: false |
Organization: This is the main base of the CMS. This is the main roof under which we create all other things. More can be found here.
Domain: There can be a lot of domains under one organisation. But for our plan, we will have only one domain per installation. More can be found here.
There are 2 ways to create users in Unite:
API working behind this action is
1 2 |
name: unitecms_core_organizationuser_createinvite URL path: /{organization}/user/create-invite |
API working behind creating a new member from here is
1 2 |
name: unitecms_core_domainmember_create URL path: /{organization}/{domain}/member/{member_type}/create |
As this CMS is based on Symfony 4, template overriding is done based on the framework.
Presently the emails sent by the system is based on the Twig templates. We can override any of these templates in the following way:
/Resources/views
folder of that particular bundle/Resources/views
Just like the templates, we can also override the translations. Translations are not based on bundles like the templates but on translation domains.
Presently the emails sent by the system is based on the Twig templates. We can override any of these templates in the following way:
The content type and/or settings type are used to define any type of content in the CMS. The difference between content type and the settings type is just that, content types can have multiple objects of the same type but the settings type can have only one object per type. Some sample type should be like below code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
{ "title": "Carousels", "identifier": "carousel", "fields": [ { "title": "Carousel Title", "identifier": "title", "type": "text" }, { "title": "Carousel Images", "identifier": "images", "type": "collection", "settings": { "fields": [ { "title": "Image", "identifier": "image", "type": "image", "settings": { "bucket": { "endpoint": "https://s3.eu-central-1.amazonaws.com", "region": "S3 REGION", //"eu-central-1" "key": "S3 KEY", "secret": "S3 SECRET", "bucket": "S3 BUCKET NAME" } } }, { "title": "Image Headline", "identifier": "headline", "type": "text" }, { "title": "Image Details", "identifier": "details", "type": "wysiwyg" } ] } } ] } |
By default Unite CMS can be translated to any number of languages. All the languages can be defined as an array of 2 character language codes. This should be defined per content type objects explicitly. For example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
{ "content_types": [ { "title": "Content Type", ... "locales": ["en", "de", "fr"] } ], "setting_types": [ { "title": "Setting Type", ... "locales": ["en", "de"] } ] } |
For convenience of the developers, we can also create variable and use them in different places. Some good candidate could be the wysiwyg settings or the S3 bucket information.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
{ "title": "My domain", "identifier": "my_domain", ..., "variables": { "@wysiwyg_settings": { "toolbar": [ "bold", "italic", "blockQuote", "|", "link", ], "heading": [ "p", "h1", "h2", "h3" ] } }, "content_types": [ { ..., "fields": [ { "title": "Content", "identifier": "content", "type": "wysiwyg", "settings": "@wysiwyg_settings" }, { "title": "Footer", "identifier": "footer", "type": "wysiwyg", "settings": "@wysiwyg_settings" } ] } ] } |
There are many predefined field types to work with Unite CMS which should be sufficient for start with.
A preview can be defined to every content type. To define the preview we need to define the preview URL and the fields to query. For example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
{ ..., "fields": [ { "title": "Header", "identifier": "header", "type": "wysiwyg", }, { "title": "Footer", "identifier": "footer", "type": "wysiwyg", "settings": "@wysiwyg_settings" } ], "preview": { "url": "http://www.mydomain.com/content/preview.php", "query": "query { header, footer }" } } |
Some code to create some basic content types and setting type are bellow. The title and the identifier of the domain should be changed per project.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 |
{ "title": "@title", "identifier": "@domain", "variables": { "@title": "CMS", "@domain": "cms", "@wysiwyg_settings": { "toolbar": [ "bold", "italic", "blockQuote", "|", "link", "|", "bulletedList", "numberedList", "|", "blockQuote", "|", "insertTable", "tableColumn", "tableRow", "mergeTableCells" ], "heading": [ "p", "h1", "h2", "h3", "h4", "h5", "h6", "code" ] }, "@s3_bucket": { "endpoint": "https://s3.eu-central-1.amazonaws.com", "region": "S3 REGION", // example: "eu-central-1" "key": "S3 KEY", // example: "AKXXIXXXKZJXROXXXXX" "secret": "S3 SECRET", // example: "2GqRoiPrigP" "bucket": "S3 BUCKET" // example: "unite-cms" }, "@locales": [ "de", "en", "it" ], "@alignments": { "Left": "left", "Right": "right", "Top": "top", "Bottom": "bottom" }, "@image_cropping": { "Circle": "circle", "Square": "square", "Rectangle": "rectangle" }, "@content_block_variants": [ { "title": "Only Text", "identifier": "only_text", "icon": "align-left", "fields": [ { "title": "Content Text", "identifier": "text", "type": "wysiwyg", "settings": "@wysiwyg_settings" } ] }, { "title": "Text & Image", "identifier": "text_image", "icon": "image", "fields": [ { "title": "Content Text", "identifier": "text", "type": "wysiwyg", "settings": "@wysiwyg_settings" }, { "title": "Content Image", "identifier": "image", "type": "image", "settings": { "bucket": "@s3_bucket" } }, { "title": "Image Position", "identifier": "image_align", "type": "choice", "settings": { "choices": "@alignments" } }, { "title": "Image Cropping", "identifier": "image_crop", "type": "choice", "settings": { "choices": "@image_cropping" } } ] }, { "title": "Text & Image with Headline", "identifier": "text_image_headline", "icon": "image", "fields": [ { "title": "Headline", "identifier": "headline", "type": "text" }, { "title": "Content Text", "identifier": "text", "type": "wysiwyg", "settings": "@wysiwyg_settings" }, { "title": "Content Image", "identifier": "image", "type": "image", "settings": { "bucket": "@s3_bucket" } }, { "title": "Image Position", "identifier": "image_align", "type": "choice", "settings": { "choices": "@alignments" } }, { "title": "Image Cropping", "identifier": "image_crop", "type": "choice", "settings": { "choices": "@image_cropping" } } ] } ] }, "content_types": [ { "title": "Webpages", "identifier": "webpage", "fields": [ { "title": "Webpage Title", "identifier": "title", "type": "text" }, { "title": "Webpage Description", "identifier": "description", "type": "text" }, { "title": "Webpage Keywords", "identifier": "keywords", "type": "text" }, { "title": "Webpage Content", "identifier": "content", "type": "collection", "settings": { "fields": [ { "title": "Webpage Content Block", "identifier": "block", "type": "variants", "settings": { "variants": [ { "title": "Header Image/Video", "identifier": "header", "icon": "image", "fields": [ { "title": "Text Contents", "identifier": "content", "type": "reference", "settings": { "domain": "cms", "content_type": "header", "view": "all", "content_label": "{id}" } } ] }, { "title": "Contents", "identifier": "types", "fields": [ { "title": "Choose Content Type", "identifier": "content", "type": "variants", "settings": { "variants": "@content_block_variants" } } ] }, { "title": "Carousel", "identifier": "carousel", "icon": "film", "fields": [ { "title": "Text Contents", "identifier": "content", "type": "reference", "settings": { "domain": "cms", "content_type": "carousel", "view": "all", "content_label": "{id}" } } ] }, { "title": "Gallery", "identifier": "gallery", "icon": "grid", "fields": [ { "title": "Text Contents", "identifier": "content", "type": "reference", "settings": { "domain": "cms", "content_type": "gallery", "view": "all", "content_label": "{id}" } } ] } ] } }, { "title": "Webpage Content Block Position", "identifier": "pos", "type": "sortindex" } ] } } ], "locales": "@locales", "views": [ { "title": "All", "identifier": "all", "type": "table", "settings": { "fields": [ "id", "title", "locale" ] } } ], "preview": { "url": "http://my.app:8080/preview.php", "query": "query { title, description }" }, "webhooks": [ { "query": "query { text }", "url": "http://my.app:8080/webhook", "condition": "event == \"update\"" } ], "permissions": { "view content": "member.data.can_edit == 1" }, "validations": [ { "expression": "content.data.title != ''", "message": "A webpage must have a title", "path": "title", "groups": [ "CREATE", "UPDATE" ] } ] }, { "title": "Headers", "identifier": "header", "fields": [ { "title": "Choose Header Type", "identifier": "types", "type": "variants", "settings": { "variants": [ { "title": "Image Collection", "identifier": "image_collection", "icon": "image", "fields": [ { "title": "Images", "identifier": "images", "type": "collection", "settings": { "fields": [ { "title": "Image", "identifier": "image", "type": "image", "settings": { "bucket": "@s3_bucket" } }, { "title": "Image Position", "identifier": "pos", "type": "integer" } ] } } ] }, { "title": "Video Collection", "identifier": "video_collection", "icon": "video", "fields": [ { "title": "Videos", "identifier": "videos", "type": "collection", "settings": { "fields": [ { "title": "Video", "identifier": "video", "type": "file", "settings": { "bucket": "@s3_bucket" } }, { "title": "Video Format", "identifier": "format", "type": "choice", "settings": { "choices": { "MP4": "mp4", "OGG": "ogg" } } } ] } } ] } ] } } ], "views": [ { "title": "All", "identifier": "all", "type": "table", "settings": { "fields": [ "id" ] } } ] }, { "title": "Carousels", "identifier": "carousel", "fields": [ { "title": "Carousel Title", "identifier": "title", "type": "text" }, { "title": "Carousel Images", "identifier": "images", "type": "collection", "settings": { "fields": [ { "title": "Image", "identifier": "image", "type": "image", "settings": { "bucket": "@s3_bucket" } }, { "title": "Image Headline", "identifier": "headline", "type": "text" }, { "title": "Image Details", "identifier": "details", "type": "wysiwyg", "settings": "@wysiwyg_settings" } ] } } ], "locales": "@locales" }, { "title": "Galleries", "identifier": "gallery", "fields": [ { "title": "Gallery Title", "identifier": "title", "type": "text" }, { "title": "Gallery Images", "identifier": "images", "type": "collection", "settings": { "fields": [ { "title": "Image", "identifier": "image", "type": "image", "settings": { "bucket": "@s3_bucket" } }, { "title": "Image Headline", "identifier": "headline", "type": "text" }, { "title": "Image Details", "identifier": "details", "type": "wysiwyg", "settings": "@wysiwyg_settings" }, { "title": "Image Tags", "identifier": "tags", "type": "collection", "settings": { "fields": [ { "title": "Image Tag", "identifier": "tag", "type": "reference", "settings": { "domain": "cms", "content_type": "tags", "view": "all", "content_label": "{name}" } } ] } } ] } } ], "locales": "@locales" }, { "title": "Navigations", "identifier": "nav", "fields": [ { "title": "Link Title", "identifier": "title", "type": "text" }, { "title": "Link", "identifier": "link", "type": "text" }, { "title": "Content", "identifier": "content", "type": "reference", "settings": { "domain": "cms", "content_type": "webpage", "view": "all", "content_label": "{title}" } }, { "title": "Parent", "identifier": "parent", "type": "reference", "settings": { "domain": "cms", "content_type": "nav", "content_label": "{title}" } }, { "title": "Child", "identifier": "child", "type": "reference_of", "settings": { "domain": "cms", "content_type": "nav", "reference_field": "parent" } }, { "title": "Position", "identifier": "pos", "type": "sortindex" } ], "locales": "@locales", "views": [ { "title": "Tree View", "identifier": "nav_view", "type": "tree", "settings": { "children_field": "child", "sort": { "field": "pos", "sortable": true } } } ] }, { "title": "Tags", "identifier": "tags", "fields": [ { "title": "Tag Name", "identifier": "name", "type": "text" } ], "locales": "@locales" } ], "setting_types": [ { "title": "Common", "identifier": "settings_common", "fields": [ { "title": "Website Title", "identifier": "website_title", "type": "text" }, { "title": "Website Logo", "identifier": "website_logo", "type": "image", "settings": { "bucket": "@s3_bucket" } }, { "title": "Google Analytics", "identifier": "google_analytics", "type": "text" }, { "title": "Static Assets", "identifier": "static_assets", "type": "collection", "settings": { "fields": [ { "title": "Asset Title", "identifier": "static_assets_title", "type": "text" }, { "title": "Asset URL", "identifier": "static_assets_url", "type": "text" } ] } }, { "title": "Website Footer", "identifier": "website_footer", "type": "wysiwyg", "settings": "@wysiwyg_settings" } ], "locales": "@locales", "views": [ { "title": "All", "identifier": "all", "type": "table" } ], "permissions": { "view setting": "true", "update setting": "member.type == \"editor\"" } } ], "domain_member_types": [ { "title": "Editor", "identifier": "editor", "domain_member_label": "{accessor}", "fields": [ { "title": "Can Edit", "identifier": "can_edit", "type": "choice", "settings": { "choices": { "Allow": "1", "Deny": "0" } } } ] }, { "title": "Viewer", "identifier": "viewer", "domain_member_label": "{accessor}", "fields": [] }, { "title": "Visitor", "identifier": "visitor", "domain_member_label": "{accessor}", "fields": [ { "title": "Test Field", "identifier": "test_field", "type": "text" } ] } ], "permissions": { "view domain": "true", "update domain": "false" } } |
All the permission are based on Symfony Expression Language. Anything executed by this expression will be translated to the boolean value. If this value is true, then the user will have the permission to the action. There are two types of permission
1. Domain based
for example:
1 2 3 4 |
"permissions": { "view domain": "true", "update domain": "member.type == \"editor\" or member.data.can_edit_domains == true", } |
2. Content based
for example:
1 2 3 4 5 6 7 |
"permissions": { "view content": "member.data.project_admin_for == content.project", "list content": "member.type == \"editor\" or member.accessor.type == \"api_key\"", "create content": "member.type == \"editor\"", "update content": "member.accessor.id == content.my_author_field", "delete content": "member.data.manager_since < content.date_of_receipt" } |
Custom fields can be added to a group of users. These fields can be later used for some different purposes like permission check. This field can be accessed as “member.data.{field_identifier}”. For example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
"domain_member_types": [ { "title": "Editor", "identifier": "editor", "domain_member_label": "{accessor}", "fields": [ { "title": "Can Edit", "identifier": "can_edit", "type": "choice", "settings": { "choices": { "Allow": "1", "Deny": "0" } } } ] } ] |
Unite CMS uses GraphQL to get data from the database via its API. A short documentation can be found in their docs.
GraphQL Playground could be a good tool to execute some GraphQL queries. An online version is also available here. A small documentation for this could also be found in the docs of the Unite CMS.
To get all webpage content from the CMS domain from our sample code in point number 6.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
query { findWebpage { result { ...webpage } } } fragment webpage on WebpageContent { title description keywords content { block { ...headerBlock ...contentBlock ...carouselBlock ...galleryBlock } pos } } fragment headerBlock on WebpageContentContentBlockHeaderVariant { content { types { ... on HeaderContentTypesImage_collectionVariant { images { image { name url } pos } } ... on HeaderContentTypesVideo_collectionVariant { videos { video { name url } format } } } } } fragment contentBlock on WebpageContentContentBlockTypesVariant { content { ... on WebpageContentContentBlockTypesContentOnly_textVariant { text } ... on WebpageContentContentBlockTypesContentText_imageVariant { text image { name url } image_crop image_align } ... on WebpageContentContentBlockTypesContentText_image_headlineVariant { headline text image { name url } image_crop image_align } } } fragment carouselBlock on WebpageContentContentBlockCarouselVariant { content { title images { headline details image { name url } } } } fragment galleryBlock on WebpageContentContentBlockGalleryVariant { content { title images { headline details image { name url } tags { tag { name } } } } } |
There are still a few points that have not yet implemented in the CMS. A roadmap for the application can be found here.
Documentation – Unite CMS documentation
Gitlab – Unite CMS repository
Gitter – Unite CMS lobby
Tutorials – Official tutorials (but sometimes they are outdated)
Like!! Great article post.Really thank you! Really Cool.