Skip to content

Developpement

Jérémy Munsch edited this page Jul 16, 2020 · 5 revisions

Developpement

Generalities

The general approach is the following:

  • An api with laravel
  • A front office written with coffee script
  • Sass compiled CSS

Things should be automated as mush as possible.

API

  • Every route should be named and place in the API group, also a specific controller should be used for the task. An already existing one can be used only if it has sense to regroup functions.
  • Each controller method should be as short as possible. And one or more specific test should be proposed in a separated file.
  • The right HTTP method should be used for the function. Also, parameters has to be checked.
  • Each php file has to comply with PSR-2, PSR-7 and camelCase must be used for file naming, and every thing except class names, for these use PascalCase.
  • String manipulation has to be UTF-8 friendly for i18n sake. As Laravel requires php-mbstring (mbstring extension), you can either us built-in laravel helper methods, or use mb_ functions or implements one if it is justified. Also there are already mb function in OmenHelper

Front office

Code is written with Coffee Script here. It is organised with modules
app.coffee is used to load modules (internal and externals) omenApi is used to store things such as config or inodes tools contains reusable modules omen contains code with each function. A separation is made by functionality.

As a following guide please take in consideration the followings:

  • Long functions should be scoped in parentheses, and short one should be written inline if possible
  • require instruction should be in top of the files
  • every module loaded is done after DOM is loaded
  • If you have some advises for organizing code and test for this JS part please advise us.

Sass compilation

To run sass compilation follow Compilation instructions
You can find sass file here. A separation is made for each part or functionality.

You can inherit a package file by loading them in app.scss and override variables in _vendorVariables.scss or overload properties in overload.scss

If you need to use a less package you can load it from dependency.less

Compilation

For a quick start please follow Installation.
The tool used for compilation operation is Yarn, you can find its instruction in composer.json.

    "tinymce": compile tinymce file plugin
    "tinymce-watch": watch for tinymce file changes and compile
    "dev": compile all files (JS, CSS) and output usable package assets in resources folder with maps and debug files
    "watch": will do the same as above and watch for changes, this is the recommended option for developpement
    "production": will compile files ready for production,
    "clean": will cleanup resources folder,
    "dist": An alias for production

Development environment

You should use a web server of your own to do this, There are no ready solutions yet. So you will need to have a blank Laravel project and install omen in it using installation instructions.

To be easier, you can modify composer.json with the following :

"repositories": {
    "kwaadpepper/laravel-omen": {
        "type": "vcs",
        "url": "https://github.com/Kwaadpepper/Omen.git",
    }
}

or if you have a specific folder cloned from https://github.com/Kwaadpepper/Omen.git

"repositories": {
    "kwaadpepper/laravel-omen": {
        "type": "path",
        "url": "pathToFolder/laravel-omen-git-pull-from-github.git",
        "options": {
            "symlink": true
        }
    }
}

Then run composer require kwaadpepper/laravel-omen

You should use method 2, and you can then work easily with your code editor while refreshing the page. Don't forget to set your Laravel project to debug mode or omen config.

You can also publish things such as config or assets.