3

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?

  • Can you run php -f /var/www/html/staging/bin/magento -vvv setup:di:compile-multi-tenant – KAndy Jun 24 '16 at 7:17
  • @KAndy thank you for the suggestion, please see output in updated question above. – Vasily802 Jun 24 '16 at 17:25
1

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

  • And indeed, my Block\Main appeared to be in wrong directory. After I moved it, the cli command worked. – Vasily802 Jun 24 '16 at 22:50
1

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.

  • var/di is not being created after recompilation (I cleared the cache too as you suggested). – Vasily802 Jun 23 '16 at 23:51
  • Without me doing anything, output now changed (see updated question) – Vasily802 Jun 24 '16 at 0:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.