Skip to content
dante di domenico edited this page Feb 27, 2023 · 31 revisions

BEdita Manager (aka BEM, or Manager) is the official Web application for BEdita API.

This page contains BEM informations for developers.

Install

You can create project via composer or download a release archive file.

To create project via composer:

composer create-project bedita/manager

This will create a new manager folder and install composer dependencies.

To create project from a release archive file, you choose the archive from the Manager Releases and download .zip or .tar.gz release file. Unpack it and then run composer install.

Build

Build JS/CSS bundles with yarn

yarn
yarn build-plugins
yarn build

Serve

Webserver configuration

Manager document root is /webroot folder. You can configure a virtual host on webserver to serve manager document root.

Apache example:

<Directory /var/www/manager>
    Require all granted
    AllowOverride All
</Directory>
<VirtualHost *:80>
    ServerName dev.manager.localhost
    DocumentRoot /var/www/manager/webroot
</VirtualHost>

Nginx example:

server {
    listen 80;
    listen [::]:80;
    server_name dev.manager.localhost;

    root /var/www/manager/webroot;
    index index.html index.php;

    # ...
}

Webpack proxy/webserver configuration

You can run manager using yarn and webpack proxy.

Edit config/.env, i.e.:

WEBPACK_PROXY_HOST=dev.manager.localhost
WEBPACK_PROXY_PORT=80

Then, launching yarn run dev will open a browser window proxing your dev.manager.localhost to localhost:3000, i.e.:

$ yarn run dev                                                                                                                                                                                                    yarn run v1.22.11
webpack --mode development --hot
--------------------
 Development Bundle
--------------------
[...]
[Browsersync] Proxying: http://dev.manager.localhost:80
[Browsersync] Access URLs:
 --------------------------------------
       Local: http://localhost:3000
    External: http://192.168.1.184:3000
 --------------------------------------
          UI: http://localhost:3001
 UI External: http://localhost:3001
 --------------------------------------

This way, you'll have page auto reload on js and scss changes.

Setup

Configuration main file is config/app.php. You can customize configuration by editing config/app_local.php (or in config/projects/<projectName>.php if you use multi project configuration).

Every module can have a configuration overriding the default; you can modify config/app_local.php as explained in Modules configuration.

Module access control can be set by role. Look at Module access by role.

You can edit properties display configuration to change the properties organization in templates. For more details, see Properties display.

To customize upload restrictions, you can set uploadAccepted and uploadForbidden configurations. For more details, see Upload.

A BEM instance can use multiple APIs (Projects). How? see Multi project.

Test

You find BEM tests in tests folder.

You can run tests against a docker BEdita API (versions 4 or 5). Check the latest release of bedita/bedita at BEdita Releases. Run the latest bedita/bedita docker image available:

docker run -p 8090:80 \
  --env BEDITA_API_KEY=1234567890 \
  --env BEDITA_ADMIN_USR=beditatest \
  --env BEDITA_ADMIN_PWD=beditatestpwd \
  bedita/bedita:4

or

docker run -p 8090:80 \
  --env BEDITA_API_KEY=1234567890 \
  --env BEDITA_ADMIN_USR=beditatest \
  --env BEDITA_ADMIN_PWD=beditatestpwd \
  bedita/bedita:5

Create a tests/.env file with proper environment variables, i.e.:

# local docker
export BEDITA_API="http://127.0.0.1:8090"
export BEDITA_API_KEY="1234567890"

# Set admin credentials
export BEDITA_ADMIN_USR="beditatest"
export BEDITA_ADMIN_PWD="beditatestpwd"

Run tests:

composer run test // this runs all tests
vendor/bin/phpunit tests/TestCase/Controller/AppControllerTest.php // this runs tests in a single file

High level tests should be always performed by developers, anytime something changes, expecially with code refactoring. Look at Tests Cases.