Question

I am trying to switch a Magento2 app from developer mode to production mode. When I run the console command, I get error: ltrim() expects parameter 1 to be string, object given

Full output below:

$ php bin/magento deploy:mode:set production
Enabled maintenance mode
Static content deployment start
ltrim() expects parameter 1 to be string, object given

How do I suppress this error?

UPDATE 1:

After a while, I am getting the following response:

$ php bin/magento deploy:mode:set production
Enabled maintenance mode
Static content deployment start
Requested languages: en_US
=== frontend -> Magento/blank -> en_US ===
.........................................................................
Successful: 1965 files; errors: 0
---

=== frontend -> Magento/luma -> en_US ===
.........................................................................
Successful: 2038 files; errors: 0
---

=== frontend -> MyVendor/MyTheme -> en_US ===
.........................................................................
Successful: 1971 files; errors: 0
---

=== adminhtml -> Magento/backend -> en_US ===
.........................................................................
Successful: 1843 files; errors: 0
---

=== Minify templates ===
.........................................................................
Successful: 854 files modified
---

New version of deployed files: 1466727090
Static content deployment complete
Start compilation
Command returned non-zero exit code:
`php -f /var/www/html/staging/bin/magento setup:di:compile-multi-tenant 2>&1`

UPDATE 2:

As suggested in comments, I ran setup:di:compile-multi-tenant command and got following response:

$ php -f /var/www/html/staging/bin/magento setup:di:compile-multi-tenant -vvv

  [ReflectionException]
  Class \MyVendor\MyModule\Block\Main does not exist

Exception trace:
 () at /var/www/html/staging/setup/src/Magento/Setup/Module/Di/Code/Scanner/PhpScanner.php:173
 ReflectionClass->__construct() at /var/www/html/staging/setup/src/Magento/Setup/Module/Di/Code/Scanner/PhpScanner.php:173
 Magento\Setup\Module\Di\Code\Scanner\PhpScanner->collectEntities() at /var/www/html/staging/setup/src/Magento/Setup/Module/Di/Code/Scanner/CompositeScanner.php:40
 Magento\Setup\Module\Di\Code\Scanner\CompositeScanner->collectEntities() at /var/www/html/staging/setup/src/Magento/Setup/Console/Command/DiCompileMultiTenantCommand.php:273
 Magento\Setup\Console\Command\DiCompileMultiTenantCommand->generateCode() at /var/www/html/staging/setup/src/Magento/Setup/Console/Command/DiCompileMultiTenantCommand.php:226
 Magento\Setup\Console\Command\DiCompileMultiTenantCommand->execute() at /var/www/html/staging/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:257
 Symfony\Component\Console\Command\Command->run() at /var/www/html/staging/vendor/symfony/console/Symfony/Component/Console/Application.php:874
 Symfony\Component\Console\Application->doRunCommand() at /var/www/html/staging/vendor/symfony/console/Symfony/Component/Console/Application.php:195
 Symfony\Component\Console\Application->doRun() at /var/www/html/staging/vendor/magento/framework/Console/Cli.php:49
 Magento\Framework\Console\Cli->doRun() at /var/www/html/staging/vendor/symfony/console/Symfony/Component/Console/Application.php:126
 Symfony\Component\Console\Application->run() at /var/www/html/staging/bin/magento:25

However, I do not need class \MyVendor\MyModule\Block\Main for MyModule to work. Shall I just put an empty class there?

Was it helpful?

Solution

You should remove all references to \MyVendor\MyModule\Block\Main or introduce this class.

OTHER TIPS

this suggests an issue creating the var/di folder.

sudo rm -rf var/di var/cache/ var/generation/
php bin/magento setup:di:compile

then check if the var/di directory was created.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top