513
edits
(Created page with "Category:Core {{TemplateDocDev}} = Location = The Dolibarr command line scripts must be located in the '''scripts''' directory in Dolibarr root. The scripts are then divided...") |
No edit summary |
||
| Line 1: | Line 1: | ||
[[Category:Core]] | [[Category:Core]] | ||
{{ | {{Template开发文档}} | ||
{{Template用户手册}} | |||
{{TemplateMainPageZh}} | |||
= | = 位置 = | ||
Dolibarr命令行脚本必须位于Dolibarr根目录下的 '''scripts'''目录中。脚本然后根据其使命划分为子目录。提供多个脚本作为标准。 | |||
= | = 开发新脚本 = | ||
脚本通常是针对特定需求而编写的,很可能你找不到你想要的脚本。在这种情况下,我们将解释如何开发自己的脚本。 | |||
== Step 1 - | == Step 1 - 创建脚本的框架 == | ||
第一步是在'''dev/skeletons/skeleton_scripts.php''' 中获取骨架脚本并在目录'''scripts/mydir/myscript.php'''中复制和重命名它。 | |||
一旦重命名完成,就给它执行权限。 | |||
在Linux上,这是命令: | |||
<source lang="bash"> | <source lang="bash"> | ||
cd scripts/mydir; | cd scripts/mydir; | ||
chmod a+rx myscript.php | chmod a+rx myscript.php | ||
</source> | </source> | ||
然后,运行它以查看是否可以在命令行模式下运行脚本。为此,在Linux上,键入: | |||
<source lang="bash"> | <source lang="bash"> | ||
php-cli ./myscript.php | php-cli ./myscript.php | ||
</source> | </source> | ||
或者 | |||
<source lang="php"> | <source lang="php"> | ||
php ./myscript.php | php ./myscript.php | ||
</source> | </source> | ||
必须获得以下输出: | |||
<source lang="bash"> | <source lang="bash"> | ||
Usage: myscript.php param1 param2 ... | Usage: myscript.php param1 param2 ... | ||
</source> | </source> | ||
== Step 2 - | == Step 2 - 编辑脚本代码 == | ||
修改脚本的内容以执行对您感兴趣的操作。 | |||
标签之间的所有代码 | |||
<source lang="php">// ---------- START OF YOUR CODE HERE</source> | <source lang="php">// ---------- START OF YOUR CODE HERE</source> | ||
和 | |||
<source lang="php">// ---------- END OY YOUR CODE</source> | <source lang="php">// ---------- END OY YOUR CODE</source> | ||
是提供的一个例子。 | |||
你可以删除它并把你想要的代码放进去。 | |||
请注意,在本节中,可以使用变量$db来访问Dolibarr数据库并已初始化。包含Dolibarr配置的 $conf对象也是可用的。 | |||
= | = 例子 = | ||
一些代码示例(创建订单、产品…)可用于目录'''/dev/examples/'''中。 | |||
edits