I have PrestaShop module project under PrestaShop modules folder name mymodule
Prestashop
admin
classes
modules
mymodule - sub project root
I want test module using codeception so I install it under mymodule folder.
Prestashop
admin
classes
modules
mymodule - sub project root
tests
vendor
codeception.yml
composer.json
...
All PrestaShop modules extends Module class which is under classes folder and use other classes from parent directory.
When I run codecept run inside my root project (module) I'm getting error
PHP Fatal error: Class 'Module' not found
How can I autoload parent classes in codeception so I can run test under mymodule folder ?
There are rules about the file creation in modules, you should take a look at the official documentation, which is clear about this, and basically is, if your folder is called mymodule, PrestaShop will try to find the file called mymodule.php, and this file should extend the class Module, here the folder structure.
Related
I working with code igniter v3.x and I would like to add some composer packages.
looking at application/config/config.php file, it says that will load packages inside application folder
| package auto-loader script in application/vendor/autoload.php.
However in the codeigniter package it already has a package.json that installs packages on root folder.
I suspect that the package.json on the root must hold only information about CodeIgniter it self. But I'm not sure.
So I have three options:
Create a new package.json inside the application folder and install packages inside application.
Modify the package.json on the root folder by adding new package and change autoload.php location
What is expected from a CodeIgniter Application?
Well, if you take a look at the Codeigniter Documentation you can see there is a Configuration setting called composer_autoload. This information can be found here.
If you set this true, Codeigniter tries to load Composer's autoload.php in the APPLICATION.'vendor' folder. If you take a closer look at the Codeigniter.php file, you'll see that you can define a directory for this setting too.
So in your case you don't have to change the package.json in the root folder because you need one in the application folder, in case you set composer_autoload to true, which i would recommend.
By the way if you try to install a package via composer in your application directory, composer asks you if you want to use the one it found on the root folder - just decline that and press n.
As you can see in the picture below (i just tried to install the mpdf package).
I have a composer based TYPO3 7.6 installation and want to create an Extbase extension with a command controller.
The controller is registered in ext_localconf.php but the commmand controller isn't found because the class is not found in typo3/sysext/extbase/Classes/Mvc/Cli/CommandManager.php in public function getAvailableCommands()
Namespace is also set: namespace Foo\FooT3monitoringNotification\Command;
The class is here Classes/Command/NotificationCommandController.php.
I've cleared all TYPO3 caches and did composer dump-autoload. Any idea, what I missed to do or what I can do to find out, why my class isn't put to autoload?
As your newly created extension is not installed via composer, you need to define where to look for the classes. Therefore you need to add an autoload section to your root composer.json (that' means not in your extension, but in your TYPO3 distribution root folder):
"autoload": {
"psr-4": {
"Foo\\FooT3monitoringNotification\\": "web/typo3conf/ext/foo_t3monitoring_notification/Classes"
}
}
More information: https://usetypo3.com/typo3-and-composer.html#c67
I have an existing PHP project. I need to test a class MyClass. I created a test under the same package.
When running with IntelliJ 2016.1 I get error Fatal error: Class 'MyClass' not found in
This is example of the test
<?php
class MyClassTest extends PHPUnit_Framework_TestCase
In Run Configuration I entered Custom working directory as the Composer vendor package.
PHPUnit is loaded from the include path
Under Settings->PHP I added the phpunit Composer package and my class package to the include path.
Under Settings->PHP->PHPUnit default config file and default bootstrap are unchecked.
What else should I configure so I can run MyClassTest without errors and test the class MyClass?
If the class is part of a composer package, or you use the composer autoloader for your project files, you can set up vendor/autoload.php as bootstrap file.
If you have set up a custom autoloader for project classes, you need to create your own boostrap.php file for PHPUnit and register the autoloader there.
Im developing a group of packag within a Laravel 5 app.
all the packages have the following structure.
Folder structure:
Vendor/Package/src
composer.json
"autoload": {
"psr-4": {
"Vendor\\Package\\": "src/"
}
},
I would like to be able to have a separate folder outside of the vendors/ folder that contains the packages, under development. As they are the basis for the application. NOTE: These packages will not be downloaded through composer, just auto-loaded with composer.
e.g.
\Laravel-App
\app
\bootstrap
\config
\database
\public
...
\src
The \src directory containing all the packages mentioned above.
It's not relevant that there is a composer.json inside each package, because the are not managed by composer (, yet). Their autoload definition will only be used for an autoload dump by Composer, if the package is installed/updated.
Here there are not handled by Composer, just sitting around in a folder.
There are multiple ways of solving the autoloading problem.
You could:
use the PHP autoload functions to register your own autoloader (during bootstrap)
use Laravel's Autoloader to add the path to these packages (during app bootstrap, somewhere after laravel autoloader init)
use Composer's Autoloader to add the paths to these packages (during app bootstrap, after Composer init)
but the easiest way would be to define the mapping in the autoload section of the composer.json file of your main application. Then they will be included in the dumped autoloader, after install or update of your Composer managed dependencies.
I am a symfony noob and I installed FOSUserBundle in the src/ directory of my project and everything was working fine. I wanted to move the bundle to the vendor folder to keep everything tidy but now I am getting the following error below:
ERROR:
Fatal error: Class 'FOS\UserBundle\FOSUserBundle' not found in app\AppKernel.php on line 22
Is there a file I have to update to make symfony look in the vendor folder?
You don't just move files into the vendor directory. The vendor directory is managed by Composer. The way that you add something to your vendor directory is to open the composer.json file, and add a line under "requirements" that looks something like this:
"friendsofsymfony/user-bundle": "dev-master"
The name on the left comes from the package repository at packagist.org, but the better way to find a little more about how to do this is in their documentation
That should contain everything you need to install it correctly.
Once you get it added, and run php composer.phar update from your application directory, Composer will download FOSUserBundle, place it in the vendor directory, and add it to the autoloader's namespace and classmaps.