OpenCart Intellisense
A Visual Studio Code extension that provides intellisense and "Go to Definition" functionality for OpenCart model files. This extension helps developers navigate between controller and model files more efficiently by enabling Ctrl+Click navigation on model references.
Features
- Go to Definition: Ctrl+Click on model methods to jump directly to their definitions
- Function Documentation: Hover over model methods to see their documentation and declaration
- Model Path Resolution: Automatically resolves paths for OpenCart model patterns like
$this->model_api_test
- Custom Path Configuration: Support for custom OpenCart directory structures
- Multi-Context Support: Works with both admin and catalog contexts
- PHP Support: Works with all PHP files in your OpenCart project
Installation
From VSIX File
Package the Extension
# Install vsce globally
npm install -g @vscode/vsce
# Navigate to extension directory
cd opencart-intellisense
# Create .vsix package
vsce package
Install in VS Code
Choose one of these methods:
Method 1 - Using VS Code UI:
- Open VS Code
- Press
Ctrl+Shift+X
to open Extensions panel
- Click "..." (More Actions)
- Select "Install from VSIX..."
- Navigate to and select your
.vsix
file
Method 2 - Using Command Line:
code --install-extension opencart-intellisense-0.0.1.vsix
Method 3 - Using Command Palette:
- Press
Ctrl+Shift+P
- Type "Extensions: Install from VSIX"
- Press Enter
- Select your
.vsix
file
Reload VS Code when prompted
Configuration
The extension supports custom path configuration for different OpenCart directory structures. You can configure these settings in your VS Code settings:
- Open VS Code Settings (File > Preferences > Settings)
- Search for "OpenCart Intellisense"
- Configure the following settings:
{
"opencartIntellisense.paths": {
"admin": "admin",
"catalog": "catalog",
"system": "system"
}
}
Usage
- Open any PHP file in your OpenCart project
- Hold Ctrl and hover over a model reference (e.g.,
$this->model_api_test->getData()
) to go to definition
- Simply hover over a model method to see its documentation and declaration
Available Settings
opencartIntellisense.paths
: Object containing custom paths for OpenCart directories
admin
: Path to admin directory (default: "admin")
catalog
: Path to catalog directory (default: "catalog")
system
: Path to system directory (default: "system")
Example Directory Structure
The extension now supports structures like:
your-opencart-project/
├── app/
│ ├── admin/
│ │ ├── controller/
│ │ ├── model/
│ │ └── view/
│ ├── catalog/
│ │ ├── controller/
│ │ ├── model/
│ │ └── view/
│ └── system/
│ └── library/
Path Resolution Logic
The extension follows this order when looking for model files:
- Checks the current context (admin/catalog) based on the file you're editing
- Checks the system directory
- Checks the opposite context
- Checks the root directory
File Structure
The extension expects your OpenCart project to follow the standard structure:
your-opencart-project/
└── model/
└── api/
└── Test.php
Development
Clone the Repository
git clone [repository-url]
cd opencart-intellisense
Install Dependencies
npm install
Compile
npm run compile
Debug
- Press F5 in VS Code to launch the extension in debug mode
- Use the Debug Console to view logs and errors
Uninstallation
- Open VS Code
- Go to Extensions panel (Ctrl+Shift+X)
- Find "OpenCart Intellisense"
- Click the gear icon and select "Uninstall"
Requirements
- Visual Studio Code ^1.85.0
- OpenCart project with standard directory structure
Known Issues
- Currently only supports model, class, library resolution for standard OpenCart naming patterns
- Path resolution is case-sensitive
Contributing
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details
Release Notes
0.0.4
- Enhance "Go to Definition" to navigate precisely to function declarations
- Added hover functionality to show function documentation and declaration
0.0.1 to 0.0.3
Initial release:
- Basic model resolution
- Go to definition support
- PHP file support