THELIA Forum

Welcome to the THELIA support and discusssion forum

Announcement

Rejoignez la communauté sur le Discord Thelia : https://discord.gg/YgwpYEE3y3

Offline

#1 Commande ligne pour thelia

(24-02-2015 17:23:42)


bonjour,
j'aimerais rajouter des fonctionnalitées sur la partie ligne de commande

#!/usr/bin/env php                                                             
Thelia version 2.2.0-alpha1                                                     
                                                                               
Usage:                                                                         
  [options] command [arguments]                                                 
                                                                               
Options:                                                                       
  --help           -h Display this help message.                               
  --quiet          -q Do not output any message.                               
  --verbose        -v|vv|vvv Increase the verbosity of messages: 1 for normal ou
tput, 2 for more verbose output and 3 for debug.                               
  --version        -V Display this application version.                         
  --ansi              Force ANSI output.                                       
  --no-ansi           Disable ANSI output.                                     
  --no-interaction -n Do not ask any interactive question.                     
  --env            -e The Environment name.                                     
  --no-debug          Switches off debug mode.                                 
                                                                               
Available commands:                                                             
  help                        Displays help for a command                       
  list                        Lists commands                                   
admin                                                                           
  admin:create                Create a new administrator user                   
  admin:updatePassword        change administrator password
cache
  cache:clear                 Invalidate all caches
image-cache
  image-cache:clear           Empty part or whole web space image cache
module
  module:activate             Activates a module
  module:deactivate           Deactivate a module
  module:generate             generate all needed files for creating a new Modul
e
  module:generate:model       generate model for a specific module
  module:generate:sql         Generate the sql from schema.xml file
  module:list                 List the modules
  module:refresh              Refresh modules list
sale
  sale:check-activation       check the activation and deactivation dates of sal
es, and perform the required action depending on the current date.
thelia
  thelia:config               Manage configuration variables
  thelia:dev:reloadDB         erase current database and create new one
  thelia:generate-resources   Outputs admin resources
  thelia:install              Install thelia using cli tools. For now Thelia onl
y use mysql database

ou dois-je ajouter le code ??? j'ai cherché mais je vois pas trop ou ca se situe ???
merci pour votre aide !!

Offline

Offline


ok merci , par contre comme je debute ... il est ou le fichier de config ? et c'est quoi son petit nom ??

Offline


Quel fichier de config ?


OpenStudio Toulouse

Offline


dans la donc faut rajouter la ligne suivante dans un fichier de config
In your config file :
    <commands>
        <command class="MyModule\Commands\HelloWorld.php"/>
    </commands>
c'est le fichier de config qui se trouve dans le module ? config.xml ?

Offline


j'ai créé la structure mais je vois pas mon module dans la liste !
                           
#!/usr/bin/env php                                                             
                                                                           
thelia@ssh:~/www$ php Thelia module:list                                       
#!/usr/bin/env php                                                             
+------------------------+--------+----------+---------+                       
| Code                   | Active | Type     | Version |                       
+------------------------+--------+----------+---------+                       
| Carousel               | No     | classic  | 0.9     |                       
| HookContact            | Yes    | classic  | 0.1     |                       
| HookLinks              | Yes    | classic  | 0.1     |                       
| HookNewsletter         | Yes    | classic  | 0.1     |                       
| HookSocial             | Yes    | classic  | 0.1     |
| HookProductsNew        | Yes    | classic  | 0.1     |
| HookProductsOffer      | Yes    | classic  | 0.1     |
| TheliaSmarty           | Yes    | classic  | 0.1     |
| VirtualProductControl  | Yes    | classic  | 1.0     |
| TheliaDebugBar         | Yes    | classic  | 1.0     |
| HookAnalytics          | Yes    | classic  | 0.1     |
| HookCart               | Yes    | classic  | 0.1     |
| Front                  | Yes    | classic  | 0.1     |
| Tinymce                | Yes    | classic  | 0.5     |
| HookNavigation         | Yes    | classic  | 0.1     |
| HookCurrency           | Yes    | classic  | 0.1     |
| HookLang               | Yes    | classic  | 0.1     |
| HookSearch             | Yes    | classic  | 0.1     |
| HookCustomer           | Yes    | classic  | 0.1     |
| FreeShipping           | Yes    | delivery | 1.0.1   |
| VirtualProductDelivery | Yes    | delivery | 1.0     |
| Colissimo              | No     | delivery | 1.0     |
| Klikandpay             | Yes    | payment  | 1.0     |
| Paybox                 | Yes    | payment  | 1.0.0   |
| Cheque                 | Yes    | payment  | 1.1     |
| Paypal                 | Yes    | payment  | 2.0     |

faut faire autre chose ???

structure

Répertoire de D:\DTMOE\Web\Thelia\Clapi

25/02/2015  10:54    <REP>          .
25/02/2015  10:54    <REP>          ..
25/02/2015  10:42    <REP>          Action
25/02/2015  11:44             1 422 Clapi.php
25/02/2015  11:42    <REP>          Commands
25/02/2015  10:55               202 composer.json
25/02/2015  10:53    <REP>          Config
25/02/2015  10:43    <REP>          Controller
25/02/2015  10:43    <REP>          Event
03/02/2015  15:14            35 121 LICENSE.txt
25/02/2015  10:43    <REP>          Loop
25/02/2015  10:43    <REP>          Model
25/02/2015  10:44               792 README.md
25/02/2015  10:43    <REP>          templates
               4 fichier(s)           37 537 octets

Répertoire de D:\DTMOE\Web\Thelia\Clapi\Action

25/02/2015  10:42    <REP>          .
25/02/2015  10:42    <REP>          ..
               0 fichier(s)                0 octets

Répertoire de D:\DTMOE\Web\Thelia\Clapi\Commands

25/02/2015  11:42    <REP>          .
25/02/2015  11:42    <REP>          ..
25/02/2015  11:43                 5 CreateCategory.php
               1 fichier(s)                5 octets

Répertoire de D:\DTMOE\Web\Thelia\Clapi\Config

25/02/2015  10:53    <REP>          .
25/02/2015  10:53    <REP>          ..
25/02/2015  10:50               406 config.xml
25/02/2015  10:51               473 module.xml
               2 fichier(s)              879 octets

Répertoire de D:\DTMOE\Web\Thelia\Clapi\Controller

25/02/2015  10:43    <REP>          .
25/02/2015  10:43    <REP>          ..
               0 fichier(s)                0 octets

Répertoire de D:\DTMOE\Web\Thelia\Clapi\Event

25/02/2015  10:43    <REP>          .
25/02/2015  10:43    <REP>          ..
               0 fichier(s)                0 octets

Répertoire de D:\DTMOE\Web\Thelia\Clapi\Loop

25/02/2015  10:43    <REP>          .
25/02/2015  10:43    <REP>          ..
               0 fichier(s)                0 octets

Répertoire de D:\DTMOE\Web\Thelia\Clapi\Model

25/02/2015  10:43    <REP>          .
25/02/2015  10:43    <REP>          ..
               0 fichier(s)                0 octets

Répertoire de D:\DTMOE\Web\Thelia\Clapi\templates

25/02/2015  10:43    <REP>          .
25/02/2015  10:43    <REP>          ..
               0 fichier(s)                0 octets

     Total des fichiers listés :
               7 fichier(s)           38 421 octets
              26 Rép(s)  104 200 847 360 octets libres

Offline


c'est le fichier de config qui se trouve dans le module ? config.xml ?

Oui.

j'ai créé la structure mais je vois pas mon module dans la liste !

Vide le cache : Thelia cache:clear, ou alors supprimer le contenu du répertoire cache.


OpenStudio Toulouse

Offline


toujours pas !
la structure du module est bonne ?
contenu du fichier Clapi.php

namespace Clapi\Commands;

use Thelia\Module\Clapi;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Thelia\Command\ContainerAwareCommand;


class CreateCategory extends ContainerAwareCommand
{
	protected function configure()
    {
        $this
            ->setName("clapi:createcategory")
            ->setDescription("Create new Category");
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $output->writeln("Hello world !");
    }
}

   

c'est un bon debut ?

Offline


Bien sur, ton module est dans local/modules,  et tu l'as activé ?


OpenStudio Toulouse

Offline


oui il est bien sous local/modules , par contre je ne le vois pas sous le menu module , je peux donc pas l'activer  ... j'ai dû oublier quelque chose !

Offline


Si tu ne le vois pas, c'est que ton module n'est pas correct.

Le plus simple est de partir du squelette que tu peux générer avec la commande Thelia module:generate

Tout sera bien présent et à sa place.


OpenStudio Toulouse

Offline


avec la commande  php Thelia module:generate ModuleName ca fonctionne tout de suite mieux !

Offline


je comprends , je dois pas faire comme il faut ... j'ai le message d'erreur suivant
[InvalidArgumentException]                                       
  There are no commands defined in the "clapi:create;category" namespace.

class Clapi extends ContainerAwareCommand
{
	/** @var string */
    #const DOMAIN_NAME = 'clapi';
	const MODULE_DOMAIN = 'clapi';
	
	protected function configure()
    {
		$this
            ->setName("clapi:create:category")
            ->setDescription("Create new Category")
			->addOption(
                "name-category",
                null,
                InputArgument::REQUIRED,
                "name of the category"
            )
            ->addOption(
                'desc-category',
                null,
                InputOption::VALUE_NONE,
                'description of the category'
            )			
			;
	    }

c'est bon ca ?

Offline


Si on suppose que le nom complet de ta classe est Clapi\Commands\Clapi, tu dois avoir dans le fichier "config.xml" de ton module :

 <commands>
        <command class="Clapi\Commands\Clapi "/>
<commands>

Voir la doc: http://doc.thelia.net/en/documentation/ … mands.html (ne met pas le .php, la doc est erronée !)


OpenStudio Toulouse

Offline


c'est mieux mais maintenantj'ai ca .... comme message
php Thelia  clapi
[InvalidArgumentException]       
  Command "clapi" is not defined.

namespace Clapi;
use Thelia\Module\BaseModule;
use Thelia\Command\ContainerAwareCommand;
use Thelia\Core\Translation\Translator;
use Thelia\Exception\OrderException;
use Thelia\Files
use Thelia\Log\Tlog;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Filesystem\Filesystem;
use Clapi\Commands\ClapiCreateCategory;
use Clapi\Commands\ClapiCreateProduct;


class Clapi extends ContainerAwareCommand
{
	/** @var string */
    #const DOMAIN_NAME = 'clapi';
	const MODULE_DOMAIN = 'clapi';
	
	protected function configure()
    {
        $this
            ->setName("clapi")
            ->setDescription("Insert/Update products")
			->addOption(
                "name-category",
                null,
                InputArgument::REQUIRED,
                "name of the action "
            )            			
			;
		    }

c'est bon ca ?

Last edited by axil_76 (27-02-2015 12:38:54)

Offline


Le problème n'est pas ce code, mais la déclaration de la commande dans config.xml


OpenStudio Toulouse

Offline


et donc dans la declaration c'est comme ca ?
<commands>
    <command class="Clapi\Commands\ClapiHelp"/>
</commands>
<commands>
    <command class="Clapi\Commands\ClapiCreateCategory"/>
</commands>
<commands>
    <command class="Clapi\Commands\ClapiCreateProduct"/>
</commands>

Offline


Non, comme ça (si tant est que le nom de tes classes est correct) :

<commands>
    <command class="Clapi\Commands\ClapiHelp"/>
    <command class="Clapi\Commands\ClapiCreateCategory"/>
    <command class="Clapi\Commands\ClapiCreateProduct"/>
</commands>

OpenStudio Toulouse

Offline


OK c'est bon ! ca fonctionne merci .
Peut-on appeler simplement les class pour requêter sur les catégories et produits pour commencer ... ca se trouve ou ?

Offline


bon maintenant j'ai un message d'erreur ... alors que c'etait bon avant !!!

php Thelia module:list
#!/usr/bin/env php
  [Symfony\Component\Debug\Exception\ContextErrorException]
  Notice: Undefined index: thelia in /usr/share/thelia/core/vendor/propel/propel/src/Propel/Runtime/ServiceContainer/StandardServiceConta
  iner.php line 276
module:list

une idée ?

Offline


Si ça marchait et que ça ne marche plus, c'est que quelqu'un a touché quelque chose !


OpenStudio Toulouse

Offline


ok c'est bon ! ca donne ca pour l'instant ...

 php Thelia list
#!/usr/bin/env php
Thelia version 2.2.0-alpha1

Usage:
  [options] command [arguments]

Options:
  --help           -h Display this help message.
  --quiet          -q Do not output any message.
  --verbose        -v|vv|vvv Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug.
  --version        -V Display this application version.
  --ansi              Force ANSI output.
  --no-ansi           Disable ANSI output.
  --no-interaction -n Do not ask any interactive question.
  --env            -e The Environment name.
  --no-debug          Switches off debug mode.

Available commands:
  help                        Displays help for a command
  list                        Lists commands
admin
  admin:create                Create a new administrator user
  admin:updatePassword        change administrator password
cache
  cache:clear                 Invalidate all caches
create
  create:category             Create a new category
  create:product              Create a new product
  create:provider             Create a new provider
php Thelia create:product

#!/usr/bin/env php
  [RuntimeException]
  Not enough arguments.
create:product [--Summary[="..."]] COMMAND [name] [online] [language]

je retrouve plus ou on décrit les paramètres ... c'est dans quel fichier ?

Offline


bonjour
j'ai commencé un bout de code

Thelia version 2.2.0-alpha1

Usage:
  [options] command [arguments]

Options:
  --help           -h Display this help message.
  --quiet          -q Do not output any message.
  --verbose        -v|vv|vvv Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug.
  --version        -V Display this application version.
  --ansi              Force ANSI output.
  --no-ansi           Disable ANSI output.
  --no-interaction -n Do not ask any interactive question.
  --env            -e The Environment name.
  --no-debug          Switches off debug mode.

Available commands:
  help                        Displays help for a command
  list                        Lists commands
admin
  admin:create                Create a new administrator user
  admin:updatePassword        change administrator password
cache
  cache:clear                 Invalidate all caches
clapi
  clapi:category              add/update/remove/list category
  clapi:customer              add/update/remove/list customer
  clapi:product               add/update/remove/list product

ou puis-je deposer mon module ?

Offline

Offline


il y a un petit tuto pour utiliser github ?
faut se créer un compte et apres ??