amostajo / perfex-crm
Perfex CRM library to customize hooks.
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/amostajo/perfex-crm
Requires (Dev)
- phpunit/phpunit: ^11.5
README
This repository shows how to customize Perfex CRM back-end and front-end.
NOTE: The CRM codebase is NOT IN here.
Customizations
Back-end
Back-end customizations can be done using Perfex CRM hooks, which is an event-driven customization system similar to the one created by WordPress.
Inside the /perfexcrm folder, this project has a replica of the my_functions_helper.php file with custom hooks created.
SIDE NOTE: My approach to back-end customizations implements dependency injection and ORM to avoid direct database queries and to make the code more maintainable.
use Amostajo\PerfexCRM\Samples\ClientHooks; // Bootstrap composer require '../vendor/autoload.php'; // Register hooks ClientHooks::register();
In your project
You can reuse the base Hook class in your project, by installing this package:
composer require amostajo/perfex-crm
Your hook registation class:
use Amostajo\PerfexCRM\Hook; use Amostajo\PerfexCRM\Traits\Registerable; class MyHooks extends Hook { use Registerable; public function init() { hooks()->add_action('hook_name', [$this, 'callback_method']); } public function callback_method($args) { // Your code here } }
Then in your my_functions_helper.php file, you can register your hooks:
// Bootstrap composer require __DIR__ . '/../vendor/autoload.php'; MyHooks::register();
Test
First, you will need to install composer dependencies:
composer install
You can review the hook registration and test with PHPUnit.
./vendor/bin/phpunit
Front-end
Front-end can be customized through a custom Perfex CRM theme or custom CSS.
Custom CSS
In this project, we have a custom CSS file that changes the background color of the CRM.
Inside the /perfexcrm folder, there is a custom.css file that is loaded in the CRM (real file is assets/css/custom.css).
The source file is located at assets/scss/custom.scss, which is compiled to perfexcrm/custom.css.
SIDE NOTE My approach to front-end implements vite to bundle the SCSS file and make it easier to maintain.
Compile
First, you will need to install npm dependencies:
npm install
Finally compile:
npm run build
Custom theme
Custom theming requires template replication. Ideally we want to bundle our related assets using Vite or Webpack.
Conclusion
This repository shows how to customize Perfex CRM back-end and front-end using hooks and custom CSS. The back-end customizations are done using an event-driven system, while the front-end customizations are done through a custom CSS file. This approach allows for maintainable and scalable customizations without modifying the core codebase of Perfex CRM.
Since this CRM was design mimicing WordPress customization engine, it is a great choice for WordPress developers.