Hello, I would like to use this package with Laravel .
https://github.com/dvdoug/BoxPacker
I followed instructions:
If you use Composer, just add dvdoug/boxpacker to your project's composer.json file:
{
"require": {
"dvdoug/boxpacker": "~1.5"
}
}
Otherwise, the library is PSR-4 compliant, so will work with the autoloader of your choice.
i added to my composer.json then run composer update
as result i have in my /vendor/composer/autoload_psr4.php:
'DVDoug\\BoxPacker\\' => array($vendorDir . '/dvdoug/boxpacker'),
and in my /vendor/composer/autoload_classmap.php:
'DVDoug\\BoxPacker\\Box' => $vendorDir . '/dvdoug/boxpacker/Box.php',
'DVDoug\\BoxPacker\\BoxList' => $vendorDir . '/dvdoug/boxpacker/BoxList.php',
'DVDoug\\BoxPacker\\BoxListTest' => $vendorDir . '/dvdoug/boxpacker/tests/BoxListTest.php',
'DVDoug\\BoxPacker\\Item' => $vendorDir . '/dvdoug/boxpacker/Item.php',
'DVDoug\\BoxPacker\\ItemList' => $vendorDir . '/dvdoug/boxpacker/ItemList.php',
'DVDoug\\BoxPacker\\ItemListTest' => $vendorDir . '/dvdoug/boxpacker/tests/ItemListTest.php',
'DVDoug\\BoxPacker\\PackedBox' => $vendorDir . '/dvdoug/boxpacker/PackedBox.php',
'DVDoug\\BoxPacker\\PackedBoxList' => $vendorDir . '/dvdoug/boxpacker/PackedBoxList.php',
'DVDoug\\BoxPacker\\Packer' => $vendorDir . '/dvdoug/boxpacker/Packer.php',
'DVDoug\\BoxPacker\\PackerTest' => $vendorDir . '/dvdoug/boxpacker/tests/PackerTest.php',
'DVDoug\\BoxPacker\\TestBox' => $vendorDir . '/dvdoug/boxpacker/tests/bootstrap.php',
'DVDoug\\BoxPacker\\TestItem' => $vendorDir . '/dvdoug/boxpacker/tests/bootstrap.php',
when i run phpunit i got this error
Fatal error: Interface 'DVDoug\BoxPacker\Box' not found in C:\server\packtest\vendor\dvdoug\boxpacker\tests\bootstrap.php on line 10
line 10 is:
8 namespace DVDoug\BoxPacker;
9
10 class TestBox implements Box {
I think it is installed correctly in composer I should be able to use it in a controller like "use dvdoug/boxpacker/Box"
and then use "new Box" but also there laravel complaints ...
any suggestion? I never used a non laravel package and I'm surely missing something here ...
I am going to assume, that you did not run the dump-autoload command, since you did not mentioned it. In case you do not know what this command does, click here to find out
SzkolaWEB said:
I am going to assume, that you did not run the dump-autoload command, since you did not mentioned it. In case you do not know what this command does, click here to find out
ok done i run :
C:\serverapache\htdocs\packtest>composer dumpautoload
Generating autoload files
tried run again a phpunit:
C:\server\packtest\vendor\dvdoug\boxpacker\tests>phpunit PackerTest
.php
Fatal error: Class 'DVDoug\BoxPacker\TestBox' not found in C:\server\packtest\vendor\dvdoug\boxpacker\tests\PackerTest.php on line 517
I think running phpunit should work directly ...
edit: I made a fresh laravel 5.2 installation and run commands like you suggested soon after:
C:\server\packtest>composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing dvdoug/boxpacker (1.5.2)
Loading from cache
Writing lock file
Generating autoload files
> Illuminate\Foundation\ComposerScripts::postUpdate
> php artisan optimize
Generating optimized class loader
C:\server\packtest>composer dump-autoload
Generating autoload files
C:\server\packtest>
running php unit on tests folders in vendor still same error... Am I wrong on running phpunit maybe? anyway if i create a controller in my app folder and use thepackage i got same error...
addendum:
https://github.com/dvdoug/BoxPacker/issues/38
said they resolved adding: " I have got everything to work by adding one more include: require_once $_SERVER['DOCUMENT_ROOT'] . '/../composer/vendor/dvdoug/boxpacker/tests/bootstrap.php'; "
the bootstrap contains basic implementation for packer, box, item ect ect ...
if i want to follow this solution how this "translate" into laravel system? thank guys
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community