Skip to main content
Bug Fixes

Fix October CMS 'Class Not Found' Error on Plugin Activation

Solve the frustrating 'Class Not Found' error when activating October CMS plugins. Learn common causes and step-by-step fixes from a seasoned web developer.

We earn commissions when you shop through the links below.
Shafat Mahmud Khan
12 min read
Fix October CMS 'Class Not Found' Error on Plugin Activation

There's little more frustrating in web development than hitting a brick wall right after you've built something new. You've just finished developing a brilliant new October CMS plugin – maybe something as complex as a custom integration for a business, or even something straightforward. You go to activate it, full of anticipation, and BAM! You're greeted with a stark, unforgiving 'Class 'Your\Plugin\Class' not found' error.

I've hit this particular 'Class not found' wall more times than I can count, especially when I was building out new features for plugins like my OpenWA WhatsApp Gateway, which integrates deeply with WooCommerce to send notifications, OTPs, and PDF invoices. This isn't just theory; this is real-world troubleshooting born from years of getting my hands dirty. If you're struggling to fix October CMS 'Class Not Found' error on plugin activation, you're in the right place. We'll walk through the common culprits and actionable solutions to get your plugin up and running.

What Causes the 'Class Not Found' Error in October CMS?

This error, while seemingly cryptic, usually points to a handful of common issues, primarily related to how October CMS (and PHP in general) discovers and loads classes. In my experience, working on projects from custom Laravel School ERP systems to WordPress plugins like Frontend File Explorer, I've seen these patterns repeatedly. Here are the most likely culprits, from most to least frequent:

  1. Autoloader Not Refreshed

    This is, by far, the most common reason. October CMS, built on Laravel, uses Composer for dependency management and its own internal system for autoloading plugin classes. When you add a new plugin or create new classes within an existing one, October CMS needs to be told to scan for these new files and register them. If the autoloader isn't refreshed, PHP simply won't know where to find your class file, even if it's perfectly named and structured.

  2. Incorrect Namespace or Class Name

    PHP namespaces are case-sensitive and must exactly match the directory structure and the class declaration. A typo in the namespace declaration (namespace Vendor\Plugin;), the class name (class MyClass), or how you're trying to use it (new Vendor\Plugin\MyClass()) will lead to a 'Class not found' error. This often happens if you rename files or folders manually without updating the code.

  3. File Permission Issues

    If your web server (Apache, Nginx) doesn't have the necessary read permissions for your plugin's class files, it won't be able to access and load them. This is a common oversight, especially when deploying code directly via FTP or manually copying files, often leading to frustrating 'Class not found' errors or even a white screen of death.

  4. Caching Problems

    October CMS aggressively caches various aspects of your application – configuration, routes, and even some aspects of the autoloader. Stale cache entries can prevent the system from recognizing newly added classes or plugin registrations.

  5. Missing Composer Dependencies

    If your October CMS plugin itself relies on external libraries managed by Composer, and you haven't run composer install or composer update in your project root, those dependencies won't be available, leading to 'Class not found' errors for the dependency classes. While less common for the plugin's primary class, it's a possibility for nested dependencies.

  6. Incorrect Folder Structure

    October CMS expects plugins to follow a specific folder structure (e.g., plugins/Vendor/PluginName/Plugin.php, plugins/Vendor/PluginName/classes/MyClass.php). If your class file isn't in the expected location relative to its declared namespace, the autoloader won't find it.

Screenshot of October CMS admin panel showing a
The infamous 'Class not found' error message in the October CMS admin panel, often appearing after attempting to activate a new or updated plugin. This is a common sight I've faced when deploying new features for clients.

Step-by-Step Guide to Fix October CMS 'Class Not Found' Error

Now that we understand the potential causes, let's get into the actionable solutions. I recommend going through these steps in order, as the first few are the most common and easiest fixes.

Step 1: Clear Caches and Update the October CMS System

This is your first line of defense and often the solution. October CMS needs to re-scan for new files and refresh its internal registry.

Access your server via SSH. If you're using a managed hosting provider like Kinsta, they usually provide excellent SSH access and support. For custom setups or when using a VPS like those from DigitalOcean, you'll need to SSH in yourself.

Navigate to your October CMS project's root directory and run the following commands:

php artisan cache:clear
php artisan october:clear
php artisan october:up

  • php artisan cache:clear: Clears the application's cached data.
  • php artisan october:clear: Specifically clears October CMS's compiled views, system files, and other internal caches. This is crucial for plugin discovery.
  • php artisan october:up: This command performs any outstanding migrations and, importantly for us, refreshes the plugin registration and class manifest. Think of it as telling October CMS, "Hey, wake up and re-read everything!"

After running these, try activating your plugin again or refreshing the page where the error occurred.

Step 2: Rebuild Composer Autoload Files

October CMS leverages Composer's autoloader. If your plugin introduces new classes or relies on Composer-managed dependencies, manually rebuilding the autoloader can resolve the 'Class not found' error.

While still in your project's root directory via SSH, execute:

composer dump-autoload

This command regenerates the vendor/autoload.php file, which maps namespaces to their physical file paths. This is something I frequently rely on for my Laravel-based projects, like the School ERP system or the Point of Sale application, whenever I add new classes or update dependencies. It's a fundamental step for PHP applications using Composer.

Step 3: Verify Namespace, Class Name, and File Path

This step requires a careful manual inspection of your plugin's code. Errors here can be subtle but fatal.

  1. Check the Plugin.php file: Ensure your main plugin class in plugins/Vendor/PluginName/Plugin.php has the correct namespace and class name that matches the directory structure (e.g., namespace Vendor\PluginName; and class Plugin extends PluginBase).

  2. Inspect the offending class file: Locate the specific class file that October CMS reports as 'not found'. Verify:

    • The namespace declaration at the top of the file exactly matches its folder path (e.g., a file at plugins/Vendor/PluginName/classes/MyUtility.php should have namespace Vendor\PluginName\Classes;).
    • The class name itself (e.g., class MyUtility) is correct and matches how you're instantiating it.
    • Any use statements where you're calling this class are accurate and fully qualified.
    • The filename matches the class name (e.g., MyUtility.php for class MyUtility).

Using a good IDE with extensions, like those I mentioned in Best VS Code Extensions For Web Developers, can highlight namespace and class name mismatches instantly, saving a lot of headaches.

Step 4: Check File Permissions

Incorrect file permissions are a silent killer. Your web server user needs to be able to read your plugin files. Common permission issues are files being too restrictive or owned by the wrong user.

Via SSH, navigate to your October CMS root directory and run:

sudo find . -type f -exec chmod 644 {} \;
sudo find . -type d -exec chmod 755 {} \;
sudo chown -R www-data:www-data storage bootstrap/cache plugins

Note: www-data is a common web server user on Ubuntu/Debian. On CentOS/RHEL, it might be nginx or apache. You might need to adjust the user and group accordingly. The storage and bootstrap/cache directories need write permissions (775 or 777 in some cases, but 775 is generally preferred). The plugins directory, and your plugin's files within it, primarily need read access (644 for files, 755 for directories).

Step 5: Run Composer Install/Update (If Applicable)

If your plugin includes its own composer.json file in its root (e.g., plugins/Vendor/PluginName/composer.json) or requires specific packages, you might need to ensure those dependencies are installed.

First, check if your plugin has a composer.json. If so, navigate to that plugin's directory and run:

composer install

Then, return to your October CMS root directory and repeat Step 1 and Step 2 to ensure the main application's autoloader is aware of these newly installed dependencies.

Step 6: Re-upload the Plugin Files

Sometimes, files can become corrupted during transfer, or not all files might be uploaded correctly if you're using FTP. If you've tried everything else, a fresh upload of your plugin's files can resolve subtle issues. Delete the plugin's folder (e.g., plugins/Vendor/PluginName) and re-upload it completely. Make sure to run the cache clearing and autoloader commands (Step 1 and Step 2) after re-uploading.

Step 7: Check PHP Version Compatibility

While less directly related to a 'Class not found' error, an incompatible PHP version can sometimes lead to obscure errors that prevent proper class loading or file parsing. If your plugin uses modern PHP features (e.g., PHP 8.0+ syntax) but your server runs an older PHP version, it could lead to parse errors that might manifest strangely. Ensure your server's PHP version meets your October CMS and plugin requirements.

Verify the Fix

After performing the steps above, the verification process is straightforward:

  1. Try to activate your plugin again from the October CMS backend.
  2. Navigate to the page or section of your website where the plugin's functionality is expected to be used.
  3. Check your server's PHP error logs (e.g., /var/log/apache2/error.log or /var/log/nginx/error.log) for any new errors.
  4. If the 'Class not found' error disappears and your plugin functions as expected, you've successfully resolved the issue!

Prevention is Better Than Cure

After fixing an error, the next logical step is to prevent it from happening again. My work on complex full-stack applications and client projects has taught me that prevention is always better than cure. Here's what I've learned from years of building systems like the OpenWA WhatsApp Gateway and School ERP:

  • Utilize Staging Environments

    Never deploy directly to production without testing. When I'm deploying client projects, especially high-traffic ones, I always insist on Kinsta for its excellent managed WordPress and application hosting, which includes robust staging environments. This eliminates surprises and allows you to catch 'Class not found' errors or similar issues before they impact live users.

  • Employ Version Control (Git)

    Always use Git. It allows you to track changes, revert to previous versions, and ensures consistency across development, staging, and production environments. This dramatically reduces issues caused by missing or incorrect files.

  • Automate Deployments

    Manual deployments are prone to human error. For my custom Laravel applications, like the School ERP or the repair service shop POS, where I need full server control and a streamlined deployment process, DigitalOcean is my preferred choice. You can set up custom shell scripts to automate tasks like cache clearing, dependency installation, and running php artisan october:up, much like I described in Automating Repetitive Tasks with Shell Scripts. This ensures all necessary post-deployment steps are consistently executed.

  • Regular Updates and Backups

    Keep October CMS and your plugins updated. Also, maintain regular backups. For smaller projects or personal blogs, Hostinger is a fantastic budget-friendly option that often includes easy backup solutions and one-click installers, making updates less daunting.

  • Code Review and Linting

    Even for personal projects, a quick code review or using PHP linting tools can catch syntax errors or namespace issues before deployment.

FAQ

Q: Why does October CMS need cache clearing so often?

A: October CMS, like many modern PHP frameworks, heavily relies on caching to boost performance. It caches configuration, views, and even plugin registrations. While beneficial, this can lead to 'stale' cached data when changes are introduced, especially new classes or plugin files. Clearing the cache forces the system to re-read and re-compile everything, ensuring it recognizes the latest code. It's a necessary trade-off for speed.

Q: Can a PHP version difference cause this error?

A: Directly, a 'Class not found' error isn't usually caused by a PHP version difference. However, an incompatible PHP version can lead to parse errors (e.g., trying to use PHP 8 syntax on a PHP 7 server). These parse errors can sometimes prevent a class file from being loaded or properly interpreted, which might indirectly manifest as a 'Class not found' if the autoloader can't process the file. Always ensure your server's PHP version matches the requirements of your October CMS version and its plugins.

Q: Is composer dump-autoload always necessary?

A: Not always for every single change, but it's crucial when you add new classes, move existing ones, or change namespaces within your plugin, especially if those classes are not directly registered through October CMS's main Plugin.php file but are part of a sub-directory or a Composer-managed dependency. The composer dump-autoload command regenerates the autoloader map, telling PHP exactly where to find each class based on its namespace. When in doubt about a 'Class not found' error, running it is a safe and often effective troubleshooting step.

Conclusion

Encountering a 'Class not found' error when you're excited to see your October CMS plugin come to life can be incredibly disheartening. But as you've seen, it's a common problem with a clear set of solutions. From refreshing the autoloader and clearing caches to meticulously checking your namespaces and permissions, these practical steps are battle-tested and proven to work. Drawing from my years of experience building everything from the OpenWA WhatsApp Gateway to custom ERPs, I know that patience and a systematic approach are your best tools.

Next time you face this error, remember to start with the basics – clear those caches! If you have further tips or specific scenarios you've tackled, feel free to share them. Happy coding!

Need help with your project?

Comments(0)

No comments yet. Be the first to share your thoughts.

Leave a comment

Your email is optional and never shown publicly.

All posts
Shafat Mahmud Khan

Shafat Mahmud Khan

WordPress & full-stack dev with 8+ years. Built OpenWA, File Explorer, ERP systems

GitHub
Recommended Hosting

Launch with Hostinger & Save 20%

Fast, reliable hosting for WordPress, Next.js, and more. Trusted by millions.

Free SSL24/7 Support1-Click WP Install99.9% Uptime
20% OFFexclusive discount
Get 20% Off

Affiliate disclosure: I earn a commission at no extra cost to you.

Related Articles