A command-line interface for OpenCart, inspired by WP-CLI. OC-CLI provides a set of command-line tools for managing OpenCart installations without using a web browser.
Created by Custom Services Limited - Your OpenCart experts.
- System Management: Check installation health, view version information
- Database Operations: Backup, restore, and manage database
- Product Management: Create, update, list, and delete products and categories
- Order Management: View and manage orders
- Extension Management: Install, activate, and manage extensions
- Cache Management: Clear and rebuild caches
- User Management: Manage admin users
- PHP 7.0 or higher
- OpenCart 2.x, 3.x, or 4.x installation
- MySQL/MySQLi support
- Composer (for installation)
composer global require custom-services-limited/oc-cli
- Clone the repository:
git clone https://github.com/Custom-Services-Limited/oc-cli.git
cd oc-cli
- Install dependencies:
composer install
- Make the binary executable:
chmod +x bin/oc
- Add to your PATH (optional):
echo 'export PATH="$PATH:'$(pwd)'/bin"' >> ~/.bashrc
source ~/.bashrc
- Navigate to your OpenCart installation directory:
cd /path/to/your/opencart
- Check if OC-CLI can detect your installation:
oc core:version
- List all available commands:
oc list
oc core:version
oc core:check-requirements
# Show database info
oc db:info
# Backup database
oc db:backup backup.sql
# Restore database
oc db:restore backup.sql
# List installed extensions
oc extension:list
# Install an extension
oc extension:install extension_name
# Enable an extension
oc extension:enable extension_name
# Disable an extension
oc extension:disable extension_name
# List modifications
oc modification:list
β = Implemented | π§ = Coming Soon (Help us by contributing!)
- β
core:version
- Display version information - β
core:check-requirements
- Check system requirements - β
core:config
- Manage OpenCart configuration
- β
db:info
- Display database connection information - β
db:backup
- Create database backup - β
db:restore
- Restore database from backup
- β
extension:list
- List installed extensions - β
extension:install
- Install an extension - β
extension:enable
- Enable an extension - β
extension:disable
- Disable an extension - β
modification:list
- List installed modifications
- β
product:list
- List products with filtering and search - β
product:create
- Create a new product with full validation - π§
product:update
- Update an existing product - π§
product:delete
- Delete a product - π§
category:list
- List categories - π§
category:create
- Create a new category
- π§
order:list
- List orders - π§
order:view
- View order details - π§
order:update-status
- Update order status
- π§
cache:clear
- Clear all caches - π§
cache:rebuild
- Rebuild caches
- π§
user:list
- List admin users - π§
user:create
- Create a new admin user - π§
user:delete
- Delete an admin user
OC-CLI can be configured using a .oc-cli.yml
file in your OpenCart root directory:
# .oc-cli.yml
database:
backup_path: ./backups
output:
format: table # table, json, yaml
cache:
enabled: true
OC-CLI supports two methods for database connectivity:
When running commands from within an OpenCart directory, OC-CLI automatically detects and reads database configuration from config.php
.
For remote database access or when config.php
is not available, use command-line database options:
# Connect directly to database
oc product:list --db-host=localhost --db-user=oc_user --db-pass=password --db-name=opencart_db
# All database connection options
--db-host=<hostname> # Database hostname (default: localhost)
--db-user=<username> # Database username
--db-pass=<password> # Database password
--db-name=<database> # Database name
--db-port=<port> # Database port (default: 3306)
--db-prefix=<prefix> # Database table prefix (default: oc_)
For detailed information about OpenCart's database structure and how OC-CLI interacts with it:
- Database Schema Documentation - Comprehensive reference for all OpenCart tables
- OpenCart 2.x & 3.x Structure - Complete database schema SQL file
- Development Guide - Database integration patterns for developers
- Commands Reference - Detailed command examples with database usage
Most commands support multiple output formats:
# Table format (default)
oc product:list
# JSON format
oc product:list --format=json
# YAML format
oc product:list --format=yaml
composer test
composer cs-check
composer cs-fix
We welcome contributions! Many commands are marked as "π§ Coming Soon" and need implementation.
How to contribute:
- Fork the repository
- Look for commands marked with π§ in the Implementation Status section
- Create a feature branch:
git checkout -b feature/implement-product-commands
- Implement the command following existing patterns in
src/Commands/
- Add tests for new functionality in
tests/
- Ensure all tests pass:
composer test
- Submit a pull request
Priority commands needing implementation:
- Additional product management commands (product:update, product:delete)
- Order management commands
- Cache management commands
- User management commands
- Category management commands
Development setup:
git clone https://github.com/Custom-Services-Limited/oc-cli.git
cd oc-cli
composer install
composer test
You can create custom commands by extending the base Command class:
<?php
namespace OpenCart\CLI\Commands\Custom;
use OpenCart\CLI\Command;
class MyCustomCommand extends Command
{
protected function configure()
{
$this
->setName('custom:my-command')
->setDescription('My custom command description');
}
protected function handle()
{
$this->io->success('Hello from my custom command!');
return 0;
}
}
OC-CLI is open source software licensed under the GPL v3 license.
- GitHub Issues - Bug reports and feature requests
- Custom Services Limited - Professional OpenCart support
- OpenCart Community Forum - General support
Custom Services Limited is a professional OpenCart development and support company. We provide:
- OpenCart development and customization
- Extension development
- Performance optimization
- Technical support and consulting
- Training and documentation
Visit us at https://support.opencartgreece.gr/ for more information about our services.
Important: This project is an independent, open-source tool created by Custom Services Limited and is NOT affiliated with, endorsed by, or officially connected to OpenCart Ltd. or the official OpenCart project.
- OpenCart is a registered trademark of OpenCart Ltd.
- This CLI tool is developed independently to help OpenCart users manage their installations
- We acknowledge that OpenCart is a trademark of OpenCart Ltd.
- This project is released under the GPL v3 license as free, open-source software
- Use of the OpenCart name in this project is purely for descriptive purposes to indicate compatibility
- Custom Services Limited and the contributors of this project disclaim any affiliation with OpenCart Ltd.
- This software is provided "as is" without warranty of any kind
- Users assume all responsibility for using this tool with their OpenCart installations
- Initial release with core commands
- Database backup/restore functionality
- Extension management commands
- System requirements checking
- OpenCart configuration management
- PHP 7.0+ compatibility