Quick links: Content - sections - sub sections
EN

Trace: creating-application

Wiki: Sitemap - Recent Changes - Back link

This is an old revision of the document!


We're going to create an application from scratch. Every Jelix application has a name : the name of its directory. We will call our application “news.org”.

We suppose that you have installed PHP 7 (or at least 5.6), PHP-CLI, and Composer.

Download

Create a directory for your project, initialise a composer.json file, and install the package jelix/jelix-standard

mkdir projects
cd projects
composer init
composer require "jelix/jelix-standard dev-jelix-1.7.x"

Note: Jelix 1.7 is not ready yet at the time we write these line (1.7.0-rc.2), so you have to indicate dev with the option minimum-stability, during composer init.

At the end, you have a new directory vendor, containing the source code of Jelix and other packages.

Discovering scripts of Jelix

Jelix is provided with several scripts to execute in a command line, which makes easy the creation and the modification of different files of a Jelix application.

The first one, vendor/bin/create-jelix-app, allows to create a Jelix application. You have to give to it the new directory of the application

Example:

vendor/bin/create-jelix-app /path/to/the/new/directory/of/the/app

Two other scripts, dev.php and console.php, are available inside the application. dev.php helps the developeur to construct his application, whereas console.php helps the administrator to manage the application data and other things.

Creation of an application

Let's begin to create our application. Go into the projects directory and type:

vendor/bin/create-jelix-app --no-default-module news.org

A number of questions are asked to you, to help you to configure the project. For this tutorial, let's keep the default answer, except for the question “How to install jelix-www files?”, for which you choose “copy”.

The web site of your company >
The licence of your application and modules (default is 'All rights reserved') >
The url to the licence if any >
Copyright on your application and modules (default is '2019 news.org') >
The suffix of your modules id (default is '@news.org') >
The creator name (your name for example) (default is 'news.org') >
The email of the creator >
How to install jelix-www files?
   copy: will be copied into the www/ directory
   filelink: a symbolic link into the www/ directory will point to the lib/jelix-www directory
   vhost: you will configure your web server to set an alias to the lib/jelix-www directory
 (default is '')
  [0] copy
  [1] vhost
  [2] filelink
 > 0
Web path to the content of lib/jelix-www? (default is 'jelix/') >
Do you want to store sessions into a database? ( 'y' or 'n', default is n) >
Do you want to store sessions as files into a specific directory? ( 'y' or 'n', default is n) >

As a result, you'll get an example/ directory, at the same level as the vendor/ directory. Its content will be :

  news.org/
     app/
         system/       the configuration files of your application
         responses/    custom response object for the application (views)
         themes/       the different possible themes in your application
         overloads/    will contain the different files that you will redefine, from modules.
     application.init.php   the file to initialize the jelix environment and the application
     console.php   the script to launch some commands to manage the application
     dev.php       the script to launch some commands to develop
     modules/      the modules of your application
     plugins/      the plugins of your application
     temp/         It contains all cache and temporary file generated by jelix.
     var/
         config/   the configuration files of your application, that are
                   specific to the environment and the server
         log/      the log files
     www/          the root directory of the site (public files)

Creation of a module

Note that we used the option --no-default-module with the script create-jelix-app. Without this option, the script create a module having the same name of the application (so news.org/modules/news.org). But in this tutorial, we want to create ourselves the module, to learn the framework.

Now we have a skeleton of application, we have to create a module, because for the moment, our application can do nothing since there is no defined action. Indeed, we will have to declare and implement some actions. An action can display a page, save data of a form, response as a webservice, etc.

The actions are grouped into distinct modules according to the domain or the function to which they are linked. We will for example create a module which will group the actions meant to display and manage the news. To do that, you have the module:create command, which takes as parameter the name of the module that will be created. Use the dev.php script inside new.org/ directory.

php dev.php module:create news --default-module

By typing this command, Jelix has created for you a module named news with all its tree structure and some mandatory files :

news.org/modules/news/
├── classes                  your business classes and services
├── controllers              your controllers
│   └── default.classic.php  a controller
├── daos                     the object-relationnal mapping files
├── forms                    forms files
├── install
│   ├── configure.php        script to configure the module
│   └── install.php          script to install the module
├── locales                  locale files ("properties" files)
│   ├── en_US
│   └── fr_FR
├── module.xml               file describing the identity of the module
├── templates                templates of the module
├── urls.xml                 urls mapping
└── zones                    objects processing specific zones in a page

We are now ready to define the actions.

en/tutorials/jelixnews-1.7/creating-application.1558605074.txt.gz · Last modified: 2019/05/23 09:51 by 127.0.0.1
Recent changes RSS feed Creative Commons License