SF2 Sylius: post-install-cmd event terminated with an exception - composer-php

I try to install sylius project with the command:
composer create-project -s dev sylius/sylius-standard
But always have the same error:
[InvalidArgumentException]
The class sylius.model.promotion_subject.class does not exists.
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache
handling the post-update-cmd event terminated with an exception
[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command.
In SyliusPromotionBundle, I noticed:
$interfaces = array(
'Sylius\Bundle\PromotionsBundle\Model\PromotionInterface' => 'sylius.model.promotion.class',
'Sylius\Bundle\PromotionsBundle\Model\CouponInterface' => 'sylius.model.promotion_coupon.class',
'Sylius\Bundle\PromotionsBundle\Model\RuleInterface' => 'sylius.model.promotion_rule.class',
'Sylius\Bundle\PromotionsBundle\Model\ActionInterface' => 'sylius.model.promotion_action.class',
'Sylius\Bundle\PromotionsBundle\Model\PromotionSubjectInterface' => 'sylius.model.promotion_subject.class',
);
So, I tried to directly add in app/parameters.yml:
sylius.model.promotion_subject.class: "Sylius\Bundle\PromotionsBundle\Model\PromotionSubjectInterface"
It seems to work, but I have the feeling it's an ugly solution...
Now: app/console sylius:install leads to:
[InvalidArgumentException]
There are no commands defined in the "doctrine:phpcr:repository" namespace.
Has anybody else encountered the same problem ?

I found strange that we have to do some operations not mentionned in the documentation. I tried again today to install the sylius project from the beginning, and everything seems fine.
As mentionned on the sylius website:
"Sylius is in the pre-alpha development stage."
I guess the team made some changes. Timon, I hope you could be successful with your installation today...
Best Regards.

Related

Module not found: Error: Can't resolve 'react-bootstrap/card' in '/tmp/build_3c0b8276/src/components/card'

I've been trying to deploy my frontend portion of my fullstack app onto Heroku (linking it to the beckend also on Heroku) but I keep getting the same error. any thoughts? follows the message below and a print of the error... Any help is much appreciated!
Module not found: Error: Can't resolve 'react-bootstrap/card' in '/tmp/build_3c0b8276/src/components/card'
Thanks,
Danilo
I've tried everything that I've found on StackFlow and other internet sources and nothing seems to work... Change bootstrap versions, reinstall, check node versions, removing package-lock and so on...

String(4) "asas" is throen in the console while running artisan command laravel

I encountered a strange error today where the error looks like in the image:
I cloned my one of my colleague's repository and ran composer install command.
As it tried to generate optimized files, the error started popping out. After that, if I try to run any artisan command, it throws the same error text string(4) "asas".
To be more precise, I already have .env configured.
Please help. Am I really missing something that I need to look at?
The most likely explanation is that your colleague dumped asas somewhere in the code base. Probably in a place that is loaded everytime you execute a command, like a service provider.
Just search for asas in all files and you'll find something like:
dd('asas');
//or
var_dump('asas');
die;
Since asas is only the result, it may be a variable, like dd($test); where asas is the value.
If you don't find anything, search for dd or var_dump.

CakePHP 3.5: Cannot access Plugin Classes after installing it via Composer

So I have a CakePHP 3 project and want to load FluentDOM, a PHP plugin not specifically written for CakePHP.
According to both software documentations, Composer is the way to go. In my understanding, all I would have to do is the following:
run composer require fluentdom/fluentdom in powershell
run composer require fluentdom/selectors-phpcss in powershell
OR
add the following to composer.json in the project's root directory:
"require": {
"fluentdom/fluentdom": "^7.0",
"fluentdom/selectors-phpcss": "^1.1"
}
run composer update in powershell
Both ways will install the desired plugins to vendor/fluentdom/{pluginname}/ as expected, but /vendor/cakephp-plugins.php won't include them, as implied by CakePHP's plugin installation manual.
The following attempt to load either plugin in a controller by writing
use Cake\Core\Plugin;
Plugin::load('fluentdom/fluentdom');
Plugin::load('fluentdom/selectors-phpcss');
would cause an exception that the desired plugins were not found in plugins/ :
Make sure your plugin fluentdom/fluentdom is in the {absolute project path}\plugins\ directory and was loaded
-- Which is already odd, because Composer wouldn't install anything there to begin with.
I found that I might get around this issue by manually extending vendor/cakephp-plugins.php to include the correct paths:
'fluentdom/fluentdom' => $baseDir . '/vendor/fluentdom/fluentdom/',
'fluentdom/selectors-phpcss' => $baseDir . '/vendor/fluentdom/selectors-phpcss/'
(However, that doesn't seem the way to go, because this file is auto-generated and overwritten by Composer after every update.)
And even then, the final issue still persists: although the plugins seem to be loaded successfully (confirmed by running Plugin::loaded()), I'd finally get the following exception when trying to access FluentDOM's classes as described in their wiki:
$document = new FluentDOM\DOM\Document();
Class 'App\Controller\FluentDOM\DOM\Document' not found
Does the plugin miss out on having its' autoload executed?
Even extending the line in my controller to Plugin::load('fluentdom/fluentdom', ['autoload' => true]);, but doesn't seem to help either; according to CakePHP's doc, that shouldn't be necessary anyway.
So what am I missing?
Found it! First of all, I had the false presumption that Plugins and Vendor Packages are more or less the same: they are not; thanks to Greg Schmidt for pointing this out in the question's comments.
The issue was in the line of how I tried to access FluentDOM's class. While
$document = new FluentDOM\DOM\Document();
worked in a standalone php file, it didn't within the Cake project; I was missing a backslash:
$document = new \FluentDOM\DOM\Document();
So, the entire path of actions to load a Vendor Package is merely:
run composer require fluentdom/fluentdom in powershell
run composer require fluentdom/selectors-phpcss in powershell
Use the new classes right away with $document = new \FluentDOM\DOM\Document();
No further steps required. Side note: Composer seems to refresh autoload config after installing a vendor file with composer require {vendor}/{package}, but in case it doesn't, or autoload config is messed up from earlier experiments, composer dumpautoload should fix it.

Codeception functional test not running, but no error

I am following the Build Larabook from scratch Laracasts tutorial (building a Facebook-like app).
In lesson 14, we implement the "sign in" feature.
Problem, when I try to run my functional test (that has been running smoothly so far), I get nothing, not even an error message:
vagrant#homestead:~/larabook$ vendor/bin/codecept run functional
Codeception PHP Testing Framework v2.0.7
Powered by PHPUnit 4.3.4 by Sebastian Bergmann.
Here is the content of my SignInCept.php:
$I = new FunctionalTester($scenario);
$I->am('a Larabook member');
$I->wantTo('login to my Larabook account');
$I->signIn();
$I->seeInCurrentUrl('/statuses');
$I->see('Welcome back!');
I tried to log out of my Vagrant vm but kept getting the same issue.
Is it possible that I broke something while updating some files?
Check carefully your signIn action in FunctionalHelper for any syntax errors. Tests fail like this without showing any errors when there is something wrong in there.
Late answer but do not use composer exec. Use the full path to codeception.
For example:
**vendor/bin/codecept run**

Laravel HTMLPurifier

I'm having a problem getting the HTMLPurifier bundle to work. I installed is as so:
php artisan bundle:install Sanitizer
then I edited application/bundles.php
'sanitize' => array('auto' => true),
when I use it:
$clean_output = Sanitize::purify($bad_input);
I get an Unhandled Exception: Class 'Sanitize' not found
I also noticed that when I try: php artisan bundle:upgrade Sanitize,
I get an error saying bundle not installed.
What am I missing?
Any help greatly appreciated.
This bundle has been setup very badly, especially with the different namings and casings. Generally a bundle uses a standard name across the board. What's happening here is that when you install the bundle it's actually installing it to bundles/laravel-htmlpurifier. What you've defined in your bundles.php file is expecting it to be installed at bundles/sanitize.
You have two options.
Option 1
Rename the laravel-htmlpurifier directory to sanitize.
Option 2
Set the location key in the bundles.php file.
'sanitize' => array('auto' => true, 'location' => 'laravel-htmlpurifier')
This should also resolve the upgrading problems you were having. You shouldn't really have to do this as it's normally the responsibility of the bundle author to ensure everything is named correctly and consistently.

Resources