Oxrun provides a cli toolset for the OXID eShop Community Edition.
Thanks to the netz98 magerun project which heavily inspired oxrun.
Disclaimer: This fork is intended for usage with OXID 6.x and up, it will not be compatible with older shop versions. Legacy commands will be removed, e.g. "install:shop" which is now handled via Composer.
PHP 5.6 is required, PHP 7 or newer is recommended.
If you are using composer (which you probably are), just add "smxsm/oxrun": "dev-develop"
to your composer.json and run composer install.
You can use the Composer CLI for this:
# add repo
composer config repositories.smxsm/oxrun vcs https://github.com/smxsm/oxrun
# add to require-dev
composer require --dev --no-scripts --no-update smxsm/oxrun:dev-develop
# update only new, with verbose output
composer update -n -vv
Or, you can edit the OXID composer.json file manually:
"repositories": {
...
"smxsm/oxrun": {
"type": "vcs",
"url": "https://github.com/smxsm/oxrun"
}
},
...
"require-dev": {
...
"smxsm/oxrun": "dev-develop"
},
You can then use oxrun by calling vendor/bin/oxrun
or add vendor/bin
to your $PATH to be able to just call oxrun
.
To use oxrun just execute php oxrun.phar
or ./vendor/bin/oxrun
(see above).
Execute oxrun inside your OXID eShop base directory (or subdirectory) if you want to interact with an existing shop. It will automatically try to find the oxid boostrap.php and load it.
If you want to run it from a different directory, you have to add the option "--shopDir=/path/to/your/shop"
.
You can use it e.g. to help you with an OXID 6 installation or deployment, e.g.:
"scripts": {
"post-update-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"@oe:ide-helper:generate",
"@oxrun:activate-modules",
"@oxrun:set-config"
],
"oxrun:activate-modules": [
"./vendor/bin/oxrun module:multiactivate configs/modules.yml -c --shopDir=./source"
],
"oxrun:set-config": [
"./vendor/bin/oxrun config:multiset configs/malls.yml --shopDir=./source"
],
This could activate some modules in different subshops and set a bunch of config variables e.g. Please note: since activating modules and updating config values requires a filled database and a valid config.inc.php file, you'd have to do some more voodoo during the OXID setup routine to make the above example work! But it should give you an idea how to use oxrun "multiactivate" and "multiset" :)
Of course, you want to add your own commands to oxrun! To do so without having to touch the vendor lib or forking the whole repository, choose one of the two possibilities:
- inside your OXID "source" directory, add a folder "oxruncmds"
- inside this folder, add the folder structure "Oxrun\Command\YOUR_PACKAGE", e.g. "Oxrun\Command\Example"
- add a command file to your new subfolder, e.g. "ExampleCommand.php".
- now add the code to your command file, e.g.:
<?php
namespace Oxrun\Command\Example;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
/**
* Class ExampleCommand
* @package Oxrun\Command\Example
*/
class ExampleCommand extends Command
{
/**
* Configures the current command.
*/
protected function configure()
{
$this
->setName('example:hello')
->setDescription('Example command')
->addOption('shopId', null, InputOption::VALUE_OPTIONAL, null);
}
/**
* Executes the current command.
*
* @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$output->writeln("<info>Hello, example</info>");
}
/**
* @return bool
*/
public function isEnabled()
{
return $this->getApplication()->bootstrapOxid();
}
}
All the command files you add here should be loaded auto-magically!
You can also add custom commands to your module folders! To do this, simply add a folder named "Commands" (or "commands" or "Command") to your module folder and add "*Command.php" files to it, e.g. "source\modules\myvendor\mymodule\Commands\FooCommand.php".
Then add the correct namespace and your command code - done!
<?php
namespace Myvendor\Mymodule\Commands;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
/**
* Class FooCommand
* @package Myvendor\Mymodule\Commands
*/
class FooCommand extends Command
{
...
-
Description: Generate a PhpStorm metadata file for auto-completion.
-
Usage:
misc:phpstorm:metadata [-o|--output-dir OUTPUT-DIR]
Generate a PhpStorm metadata file for auto-completion.
output-dir:
- Name:
--output-dir
- Shortcut:
-o
- Is value required: yes
- Description: Writes the metadata for PhpStorm to the specified directory.
-
Description: Generate a raw command documentation of the available commands
-
Usage:
misc:generate:documentation
Generate a raw command documentation of the available commands
command:
- Name: command
- Description: The command to execute
-
Description: Executes a query
-
Usage:
db:query [--raw] [--] <query>
Executes an SQL query on the current shop database. Wrap your SQL in quotes.
If your query produces a result (e.g. a SELECT statement), the output will be returned via the table component. Add the raw option for raw output.
Requires php exec and MySQL CLI tools installed on your system.
query:
- Name: query
- Description: The query which is to be executed
raw:
- Name:
--raw
- Accept value: no
- Is value required: no
- Description: Raw output
- Default:
false
-
Description: Anonymize relevant OXID db tables
-
Usage:
db:anonymize [--debug] [-d|--domain [DOMAIN]] [-k|--keepdomain [KEEPDOMAIN]]
Anonymizes user relevant data in the OXID database. Relevant tables are: Array ( [0] => oxnewssubscribed [1] => oxuser [2] => oxvouchers [3] => oxaddress [4] => oxorder )
debug:
- Name:
--debug
- Accept value: no
- Is value required: no
- Description: Debug SQL queries generated
- Default:
false
domain:
- Name:
--domain
- Shortcut:
-d
- Is value required: no
- Description: Domain to use for all anonymized usernames /email addresses, default is "@oxrun.com"
keepdomain:
- Name:
--keepdomain
- Shortcut:
-k
- Is value required: no
- Description: Domain which should NOT be anonymized, default is "@foobar.com". Data with this domain in the email address will NOT be anonymized.
-
Description: Import a sql file
-
Usage:
db:import <file>
Imports an SQL file on the current shop database.
Requires php exec and MySQL CLI tools installed on your system.
file:
- Name: file
- Description: The sql file which is to be imported
-
Description: List of all Tables
-
Usage:
db:list [-p|--plain] [-t|--pattern PATTERN]
List Tables
usage:
oxrun db:list --pattern oxseo%,oxuser
- To dump all Tables, but oxseo
, oxvoucher
, and oxvoucherseries
without data.
possibilities: oxseo%,oxuser,%logs%
plain:
- Name:
--plain
- Shortcut:
-p
- Accept value: no
- Is value required: no
- Description: print list as comma separated.
- Default:
false
pattern:
- Name:
--pattern
- Shortcut:
-t
- Is value required: yes
- Description: table name pattern test. e.g. oxseo%,oxuser
-
Description: Dumps the the current shop database
-
Usage:
db:dump [--file FILE] [-t|--table TABLE] [-i|--ignoreViews] [-a|--anonymous] [-w|--withoutTableData WITHOUTTABLEDATA]
Dump the current shop database.
usage:
oxrun db:dump --withoutTableData oxseo,oxvou%
- To dump all Tables, but oxseo
, oxvoucher
, and oxvoucherseries
without data.
possibilities: oxseo%,oxuser,%logs%
oxrun db:dump --table %user%
- to dump only those tables `oxuser` `oxuserbasketitems` `oxuserbaskets` `oxuserpayments`
oxrun db:dump --anonymous # Perfect for Stage Server
- Those table without data: `oxseo`, `oxseologs`, `oxseohistory`, `oxuser`, `oxuserbasketitems`, `oxuserbaskets`, `oxuserpayments`, `oxnewssubscribed`, `oxremark`, `oxvouchers`, `oxvoucherseries`, `oxaddress`, `oxorder`, `oxorderarticles`, `oxorderfiles`, `oepaypal_order`, `oepaypal_orderpayments`.
oxrun db:dump -v
- With verbose mode you will see the mysqldump command
(`mysqldump -u 'root' -h 'oxid_db' -p ... `)
oxrun db:dump --file dump.sql
- Put the Output into a File
** Only existing tables will be exported. No matter what was required.
Requires php, exec and MySQL CLI tools installed on your system.
file:
- Name:
--file
- Is value required: yes
- Description: Dump sql in to this file
table:
- Name:
--table
- Shortcut:
-t
- Is value required: yes
- Description: name of table to dump only. Default all tables. Use comma separated list and or pattern e.g. %voucher%
ignoreViews:
- Name:
--ignoreViews
- Shortcut:
-i
- Accept value: no
- Is value required: no
- Description: Ignore views
- Default:
false
anonymous:
- Name:
--anonymous
- Shortcut:
-a
- Accept value: no
- Is value required: no
- Description: Do not export table with person related data.
- Default:
false
withoutTableData:
- Name:
--withoutTableData
- Shortcut:
-w
- Is value required: yes
- Description: Table name to dump without data. Use comma separated list and or pattern e.g. %voucher%
-
Description: Clears the cache
-
Usage:
cache:clear [-f|--force]
Clears the cache
force:
- Name:
--force
- Shortcut:
-f
- Accept value: no
- Is value required: no
- Description: Try to delete the cache anyway. [danger or permission denied]
- Default:
false
-
Description: Returns the route. Which controller and parameters are called.
-
Usage:
route:debug [--shopId [SHOPID]] [-c|--copy] [--] <url>
Returns the route. Which controller and parameters are called.
url:
- Name: url
- Description: Website URL. Full or Path
shopId:
- Name:
--shopId
- Is value required: no
- Description:
copy:
- Name:
--copy
- Shortcut:
-c
- Accept value: no
- Is value required: no
- Description: Copy file path from the class to the clipboard (only MacOS)
- Default:
false
-
Description: Gets a config value
-
Usage:
config:get [--shopId [SHOPID]] [--moduleId [MODULEID]] [--] <variableName>
Gets a config value
variableName:
- Name: variableName
- Description: Variable name
shopId:
- Name:
--shopId
- Is value required: no
- Description:
moduleId:
- Name:
--moduleId
- Is value required: no
- Description:
-
Description: Export shop config
-
Usage:
config:export [-e|--env ENV] [-f|--force-cleanup]
Export shop config
env:
- Name:
--env
- Shortcut:
-e
- Is value required: yes
- Description: Environment to execute in
force-cleanup:
- Name:
--force-cleanup
- Shortcut:
-f
- Accept value: no
- Is value required: no
- Description: Force clean-up
- Default:
false
-
Description: Sets a shop config value
-
Usage:
config:shop:set [--shopId [SHOPID]] [--] <variableName> <variableValue>
Sets a shop config value
variableName:
- Name: variableName
- Description: Variable name
variableValue:
- Name: variableValue
- Description: Variable value
shopId:
- Name:
--shopId
- Is value required: no
- Description: oxbaseshop
- Default:
'oxbaseshop'
-
Description: Sets a config value
-
Usage:
config:set [--variableType VARIABLETYPE] [--shopId [SHOPID]] [--moduleId [MODULEID]] [--] <variableName> <variableValue>
Sets a config value
variableName:
- Name: variableName
- Description: Variable name
variableValue:
- Name: variableValue
- Description: Variable value
variableType:
- Name:
--variableType
- Is value required: yes
- Description: Variable type
shopId:
- Name:
--shopId
- Is value required: no
- Description:
moduleId:
- Name:
--moduleId
- Is value required: no
- Description:
-
Description: Import shop config
-
Usage:
config:import [-e|--env ENV]
Import shop config
env:
- Name:
--env
- Shortcut:
-e
- Is value required: yes
- Description: Environment to execute in
-
Description: Sets multiple config values from yaml file
-
Usage:
config:multiset <configfile>
YAML example:
config:
1:
blReverseProxyActive:
variableType: bool
variableValue: false
# simple string type
sMallShopURL: http://myshop.dev.local
sMallSSLShopURL: http://myshop.dev.local
myMultiVal:
variableType: aarr
variableValue:
- /foo/bar/
- /bar/foo/
# optional module id
moduleId: my_module
2:
blReverseProxyActive:
...
If you want, you can also specify a YAML string on the command line instead of a file, e.g.:
../vendor/bin/oxrun module:multiset $'config:
1:
foobar: barfoo
' --shopId=1
configfile:
- Name: configfile
- Description: The file containing the config values, see malls.yml.dist. The file path is relative to the shop root. You can also pass a YAML string on the command line.
-
Description: Sets a shop config value
-
Usage:
config:shop:get [--shopId [SHOPID]] [--] <variableName>
Sets a shop config value
variableName:
- Name: variableName
- Description: Variable name
shopId:
- Name:
--shopId
- Is value required: no
- Description: oxbaseshop
- Default:
'oxbaseshop'
-
Description: Generates a module skeleton [NOT IMPLEMENTED YET]
-
Usage:
module:generate [--shopId [SHOPID]] [--] <module>
Generates a module skeleton [NOT IMPLEMENTED YET]
module:
- Name: module
- Description: Module name
shopId:
- Name:
--shopId
- Is value required: no
- Description:
-
Description: Activates multiple modules, based on a YAML file
-
Usage:
module:multiactivate [--shopId SHOPID] [-s|--skipDeactivation] [-c|--skipClear] [--] <module>
usage: oxrun module:multiactivate configs/modules.yml
- to activate all modules defined in the file "configs/modules.yml" based on a white- or blacklist
Example:
whitelist:
1:
- ocb_cleartmp
- moduleinternals
#- ddoevisualcms
#- ddoewysiwyg
2:
- ocb_cleartmp
Supports either a "whitelist" or a "blacklist" entry with multiple shop ids and the desired module ids to activate (whitelist) or to exclude from activation (blacklist).
If you want, you can also specify a YAML string on the command line instead of a file, e.g.:
../vendor/bin/oxrun module:multiactivate $'whitelist:
1:
- oepaypal
' --shopId=1
module:
- Name: module
- Description: YAML module list filename or YAML string
shopId:
- Name:
--shopId
- Is value required: yes
- Description: The shop id.
skipDeactivation:
- Name:
--skipDeactivation
- Shortcut:
-s
- Accept value: no
- Is value required: no
- Description: Skip deactivation of modules, only activate.
- Default:
false
skipClear:
- Name:
--skipClear
- Shortcut:
-c
- Accept value: no
- Is value required: no
- Description: Skip cache clearing.
- Default:
false
-
Description: Lists all modules
-
Usage:
module:list [--shopId [SHOPID]]
Lists all modules
shopId:
- Name:
--shopId
- Is value required: no
- Description:
-
Description: Activates a module
-
Usage:
module:activate [--shopId [SHOPID]] [--] <module>
Activates a module
module:
- Name: module
- Description: Module name
shopId:
- Name:
--shopId
- Is value required: no
- Description:
-
Description: Deactivates a module
-
Usage:
module:deactivate [--shopId [SHOPID]] [--] <module>
Deactivates a module
module:
- Name: module
- Description: Module name
shopId:
- Name:
--shopId
- Is value required: no
- Description:
-
Description: Deactivate and activate a module
-
Usage:
module:reload [--shopId [SHOPID]] [--] <module>
Deactivate and activate a module
module:
- Name: module
- Description: Module name
shopId:
- Name:
--shopId
- Is value required: no
- Description:
-
Description: Fixes a module
-
Usage:
module:fix [--shopId [SHOPID]] [-b|--base-shop] [-x|--no-debug] [-r|--reset] [-a|--all] [--] [<module>]
Usage: module:fix [options] <module_id> [<other_module_id>...] This command fixes information stored in database of modules Available options: -a, --all Passes all modules -b, --base-shop Fix only on base shop -r, --reset Reset module, remove entries from config arrays --shopId=<shop_id> Specifies in which shop to fix states -x, --no-debug No debug output
module:
- Name: module
- Description: Module name
shopId:
- Name:
--shopId
- Is value required: no
- Description:
base-shop:
- Name:
--base-shop
- Shortcut:
-b
- Accept value: no
- Is value required: no
- Description:
- Default:
false
no-debug:
- Name:
--no-debug
- Shortcut:
-x
- Accept value: no
- Is value required: no
- Description:
- Default:
false
reset:
- Name:
--reset
- Shortcut:
-r
- Accept value: no
- Is value required: no
- Description:
- Default:
false
all:
- Name:
--all
- Shortcut:
-a
- Accept value: no
- Is value required: no
- Description:
- Default:
false
-
Description: Creates a new user
-
Usage:
user:create
Creates a new user
-
Description: Sets a new password
-
Usage:
user:password <username> <password>
Sets a new password
username:
- Name: username
- Description: Username
password:
- Name: password
- Description: New password
-
Description: Updates a cms page
-
Usage:
cms:update [--title [TITLE]] [--content [CONTENT]] [--language LANGUAGE] [--active ACTIVE] [--] <ident>
Updates a cms page
ident:
- Name: ident
- Description: Content ident
title:
- Name:
--title
- Is value required: no
- Description: Content title
content:
- Name:
--content
- Is value required: no
- Description: Content body
language:
- Name:
--language
- Is value required: yes
- Description: Content language
active:
- Name:
--active
- Is value required: yes
- Description: Content active
-
Description: Read EXCEPTION_LOG.txt and display entries.
-
Usage:
log:exceptionlog [-l|--lines [LINES]] [-f|--filter [FILTER]] [-r|--raw] [-t|--tail]
Read EXCEPTION_LOG.txt and display entries.
lines:
- Name:
--lines
- Shortcut:
-l
- Is value required: no
- Description: Number of lines to show
filter:
- Name:
--filter
- Shortcut:
-f
- Is value required: no
- Description: Filter string to search for
raw:
- Name:
--raw
- Shortcut:
-r
- Accept value: no
- Is value required: no
- Description: Show raw text, no table
- Default:
false
tail:
- Name:
--tail
- Shortcut:
-t
- Accept value: no
- Is value required: no
- Description: Show last lines first
- Default:
false
-
Description: Updates the views
-
Usage:
views:update
Updates the views
The unit tests require a configured shop and a database. To start the tests, run the following command in the "source" folder of your OXID 6 installation and set the correct path to the "oxrun" vendor directory, e.g.:
../vendor/bin/phpunit /var/www/html/oxid6/vendor/smxsm/oxrun/
You can generate the documentation for all available commands with
../vendor/bin/oxrun misc:generate:documentation > commands.txt
and then just copy/paste the contents of "commands.txt" into the README :)
If you want to build the phar file, you can run
php build
in the base directory. Make sure you set
phar.readonly = Off
in your php.ini file, otherwise PHP will refuse to create the file!