PHPackages                             barcodex/kasha-fscms - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. barcodex/kasha-fscms

ActiveLibrary[Framework](/categories/framework)

barcodex/kasha-fscms
====================

Dead-simple FileSystem based CMS for Kasha PHP framework

06PHP

Since Jun 1Pushed 10y ago1 watchersCompare

[ Source](https://github.com/barcodex/kasha-fscms)[ Packagist](https://packagist.org/packages/barcodex/kasha-fscms)[ RSS](/packages/barcodex-kasha-fscms/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

kasha-fscms
===========

[](#kasha-fscms)

This library provides dead easy backend for filesystem based CMS. This CMS is expected to work on top of Kasha framework, but actually it does need only very basic dependencies and does not require full Kasha stack to run.

As it can be supposed from the name, this library has no database dependencies, so it can be used on most restrictive hostings and/or can be easily moved between different servers/OSs without changing anything at all, all content is just copied with OS file management commands.

Surprising possible benefit of storing content in text files instead of the database is possibility to store it under version control.

Every post is just a serialized JSON object, so it can easily be fed to JSON-based front-ends like AngularJS.

The library consists of only one class, \\Kasha\\FSCMS\\Manager, that is responsible for searching, adding, deleting and editing posts (see section API below for more details).

*Do not use this library for complex fast-growing systems.*

Installation
------------

[](#installation)

Install FSCMS library with Composer by adding a requirement into composer.json of your project:

```
{
   "require": {
        "barcodex/kasha-fscms": "*"
   }
}
```

or requiring it from the command line:

```
composer require barcodex/kasha-fscms:*
```

Folder structure
----------------

[](#folder-structure)

Since CMS is based on the file system, it is very important to understand the folder structure.

When Manager object is instantiated, its constructor gets an address of a CMS root folder as a parameter. Under this root folder, all data is contained - the main reason is, of course, the "contents" folder. There all the posts themselves are stored. Since CMS supports different types of posts, there are as many subfolders under "contents", as there are different types. In each type folder, posts are stored one per .json file.

It is up to framework integrator to decide the structure of the post objects, but it is important to know about some reserved names for the fields, used internally by the framework and thus, unavailable to describe custom fields:

fielddescriptionidid of the post is unique throughout all typestypetype of the post, can be any stringstatuseither 'draft' or 'published'createddate of creation, as all other dates, is given in 'Y-m-d H:i:s' formatpublishedin case of status being 'published', this contains date of publishing in 'Y-m-d H:i:s' format, otherwise empty stringcreatorid of the creatorEvery post has its set of metadata, which is stored separately. To speed up the searches, metadata of all posts is stored in the same posts.json file. This file is stored in "metadata" folder inside of the CMS root folder, to make sure it is not confused with the contents.

Thus, the entire folder structure looks like this:

```
\contents
  \type1
    \id1.json
     ...
  ...
\metadata
 \posts.json

```

\## API

The main thing to remember when using FSCMS library is that we need to specify the root folder for the content. We do it when creating an instance of Manager class (in this example, let's imaging that controller script wants to store the posts in cms folder of its containing directory:

```
