Forum


Replies: 3   Views: 1847
Ns version, private respository: class not found errors
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by admin  · 21-04-2021 - 06:29

Hello,

We think the problem is you are not using the correct namespace, from the error you get:

class 'phpdocx\Create\CreateDocx' not found

Please note that the internal path is Classes/Phpdocx/Create (Phpdocx, not phpdocx; this is with the first character uppercase).

If you are using a repository (such as a private repository) to install phpdocx, composer will download and install phpdocx and then it will autoload the classes automatically,

Adding the classmap/psr-4 settings manually to composer.json is only needed when you are copying the files without using a repository.

On Integrate phpdocx with Composer projects you can read the steps to integrate phpdocx with composer copying the files of the library manually.

If you copy the files manually instead of using a repository that is loaded from Composer, the recommended way to autoload phpdocx using Composer is with the classmap option:

"autoload": {
    "classmap": [
        "vendor/phpdocx/Classes/Phpdocx"
    ]
}

not psr-4, although some users integrate it with psr-4: https://www.phpdocx.com/en/forum/default/topic/2050 too:

"psr-4": {
    "Phpdocx\\": "vendor/phpdocx/Classes/"
}

After you have added the library path to Composer you need to update the Composer autoloader (again, only if yu have copied the files manually):

$ composer dump-autoload

Also please check you are using the correct namespaces when you instantiate the classes in your code.

Integrating phpdocx with Composers and any PHP namespaces project is fully tested, so we are sure the problem comes from a not correct namespace when the class are being used.

Regards.