Skip to content

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.

License

Notifications You must be signed in to change notification settings

Custom-Services-Limited/oc-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

73 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

OC-CLI - OpenCart Command Line Interface

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.

Features

  • 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

Requirements

  • PHP 7.0 or higher
  • OpenCart 2.x, 3.x, or 4.x installation
  • MySQL/MySQLi support
  • Composer (for installation)

Installation

Via Composer (Recommended)

composer global require custom-services-limited/oc-cli

Manual Installation

  1. Clone the repository:
git clone https://github.com/Custom-Services-Limited/oc-cli.git
cd oc-cli
  1. Install dependencies:
composer install
  1. Make the binary executable:
chmod +x bin/oc
  1. Add to your PATH (optional):
echo 'export PATH="$PATH:'$(pwd)'/bin"' >> ~/.bashrc
source ~/.bashrc

Quick Start

Screenshot: alt text

  1. Navigate to your OpenCart installation directory:
cd /path/to/your/opencart
  1. Check if OC-CLI can detect your installation:
oc core:version
  1. List all available commands:
oc list

Basic Usage

Check OpenCart Version

oc core:version

System Information

oc core:check-requirements

Database Operations

# Show database info
oc db:info

# Backup database
oc db:backup backup.sql

# Restore database
oc db:restore backup.sql

Extension Management

# 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

Implementation Status

βœ… = Implemented | 🚧 = Coming Soon (Help us by contributing!)

Core Commands βœ…

  • βœ… core:version - Display version information
  • βœ… core:check-requirements - Check system requirements
  • βœ… core:config - Manage OpenCart configuration

Database Commands βœ…

  • βœ… db:info - Display database connection information
  • βœ… db:backup - Create database backup
  • βœ… db:restore - Restore database from backup

Extension Commands βœ…

  • βœ… 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 Commands βœ…

  • βœ… 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 Commands 🚧

  • 🚧 order:list - List orders
  • 🚧 order:view - View order details
  • 🚧 order:update-status - Update order status

Cache Commands 🚧

  • 🚧 cache:clear - Clear all caches
  • 🚧 cache:rebuild - Rebuild caches

User Commands 🚧

  • 🚧 user:list - List admin users
  • 🚧 user:create - Create a new admin user
  • 🚧 user:delete - Delete an admin user

Available Commands

Configuration

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

Database Connection Options

OC-CLI supports two methods for database connectivity:

1. OpenCart Installation Method (Traditional)

When running commands from within an OpenCart directory, OC-CLI automatically detects and reads database configuration from config.php.

2. Direct Database Connection (New)

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_)

Database Schema Reference

For detailed information about OpenCart's database structure and how OC-CLI interacts with it:

Output Formats

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

Development

Running Tests

composer test

Code Style

composer cs-check
composer cs-fix

Contributing

We welcome contributions! Many commands are marked as "🚧 Coming Soon" and need implementation.

How to contribute:

  1. Fork the repository
  2. Look for commands marked with 🚧 in the Implementation Status section
  3. Create a feature branch: git checkout -b feature/implement-product-commands
  4. Implement the command following existing patterns in src/Commands/
  5. Add tests for new functionality in tests/
  6. Ensure all tests pass: composer test
  7. 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

Extending OC-CLI

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;
    }
}

License

OC-CLI is open source software licensed under the GPL v3 license.

Support

About Custom Services Limited

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.

Legal Notice & Disclaimer

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

Changelog

1.0.0

  • Initial release with core commands
  • Database backup/restore functionality
  • Extension management commands
  • System requirements checking
  • OpenCart configuration management
  • PHP 7.0+ compatibility

About

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.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Contributors 2

  •  
  •  

Languages