Autoloader registery not found in autoload.php - composer-php

I was facing an error while updating my magento 2 website, because of that error i can't able to do anything ex: i can't able to compile, update & deploy static content.
Here is the error:
PHP Fatal error: Uncaught Error: Class 'Magento\Framework\Autoload\AutoloaderRe gistry' not found in /var/www/vhosts/potboy.com.my/httpdocs/app/autoload.php:37
Stack trace:
#0 /var/www/vhosts/potboy.com.my/httpdocs/app/bootstrap.php(30): require_once()
#1 /var/www/vhosts/potboy.com.my/httpdocs/bin/magento(14): require('/var/www/vho sts...')
#2 {main}
thrown in /var/www/vhosts/potboy.com.my/httpdocs/app/autoload.php on line 37
Can anyone please help me to solve this issue. i already updated the composer but still the same error exists please find this screenshot for reference
.
here is my autoload file:
<?php
/**
* Register basic autoloader that uses include path
*
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
use Magento\Framework\Autoload\AutoloaderRegistry;
use Magento\Framework\Autoload\ClassLoaderWrapper;
/**
* Shortcut constant for the root directory
*/
define('BP', dirname(__DIR__));
define('VENDOR_PATH', BP . '/app/etc/vendor_path.php');
if (!file_exists(VENDOR_PATH)) {
throw new \Exception(
'We can\'t read some files that are required to run the Magento application. '
. 'This usually means file permissions are set incorrectly.'
);
}
$vendorDir = require VENDOR_PATH;
$vendorAutoload = BP . "/{$vendorDir}/autoload.php";
/* 'composer install' validation */
if (file_exists($vendorAutoload)) {
$composerAutoloader = include $vendorAutoload;
} else {
throw new \Exception(
'Vendor autoload is not found. Please run \'composer install\' under application root directory.'
);
}
AutoloaderRegistry::registerAutoloader(new ClassLoaderWrapper($composerAutoloader));
// Sets default autoload mappings, may be overridden in Bootstrap::create
\Magento\Framework\App\Bootstrap::populateAutoloader(BP, []);

It looks like Magento not find vendor/magento/framework/Autoload/AutoloaderRegistry.php
Can you check above file is there or not and if not than first run command "composer update" from the root of your Magento installation.

Related

Laravel Homestead exception handling/pretty error message display not working

If there's an error anywhere in my code, such as in the routes file or a view, then instead of displaying the 'pretty' error message I get a dump of JS in the browser.
The error message is in there, but I have to hunt for it.
I'm using Laravel 5.8 in Homestead.
.env has APP_DEBUG=true set. I've also tried directly editing config/app.php to set debug but it doesn't work.
I'm quite new to Laravel so at a loss as to what to look at next...
Here's the first few lines of what gets dumped to the screen, please also check the attached screenshot below.
window.data = {"report":{"notifier":"Laravel Client","language":"PHP","framework_version":"6.0.3","language_version":"7.3.7-2+ubuntu18.04.1+deb.sury.org+1","exception_class":"Facade\\Ignition\\Exceptions\\ViewException","seen_at":1573633009,"message":"htmlspecialchars() expects parameter 1 to be string, array given (View: \/home\/vagrant\/pinyin\/resources\/views\/cards\/cards.blade.php)","glows":[],"solutions":[],"stacktrace":[{"line_number":251,"method":"handleError","class":"Illuminate\\Foundation\\Bootstrap\\HandleExceptions","code_snippet":{"236":"","237":"if (! function_exists(\u0027e\u0027)) {","238":" \/**","239":" * Encode HTML special characters in a string.","240":" *","241":" * #param \\Illuminate\\Contracts\\Support\\Htmlable|string $value","242":" * #param bool $doubleEncode","243":" * #return string","244":" *\/","245":" function e($value, $doubleEncode = true)","246":" {","247":" if ($value instanceof Htmlable)
Found the fix. In the webpack.mix.js file add the following to BrowserSync options:
mix.browserSync({
snippetOptions: {
rule: {
match: /<\/body>/i,
fn: function (snippet, match) {
return snippet + match;
}
}
}
});
Solution from: https://github.com/facade/ignition/issues/16#issuecomment-527260360
Found via: https://github.com/laravel/framework/issues/29909

Error throwing while sending an email using laravel [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
Error throwing while sending an email using laravel after migration the web application to a new server. It was working fine on the previous server.
Relevant error description edited in from comments:
[2018-01-25 13:31:10] production.ERROR: ErrorException: mkdir(): No
such file or directory in
/var/www/html/jbservice/vendor/swiftmailer/swiftmailer/lib/c‌​lasses/Swift/KeyCach‌​e/Disk$
Stack trace: #0 [internal function]:
Illuminate\Foundation\Bootstrap\HandleExceptions->handleErro‌​r(2,
'mkdir(): No suc...', '/var/www/html/j...', 273, Array) #1
/var/www/html/jbservice/vendor/swiftmailer/swiftmailer/lib/c‌​lasses/Swift/KeyCach‌​e/DiskKeyCache.php(2‌​73):
mkdir('/tmp/68d392a3e3...')
Relevant code edited from comments:
Mail::send('dashboard.emails.createticket', $data , function ($message)
use ($data) { $message->subject('New Ticket: ' . $data['subject'])
->to("atif#gmail.com")
->from('HERE COMES THE SENDER EMAIL'); });
You can check your log.
If it show the SwiftMailer was trying to create cache in default /tmp folder :
To solve the issue, change the TMPDIR environment variable in the boot() method of app/Providers/AppServiveProvider.php.
/**
* Bootstrap any application services.
*
* #return void
*/
public function boot()
{
/**
* Somehow PHP is not able to write in default /tmp directory and SwiftMailer was failing.
* To overcome this situation, we set the TMPDIR environment variable to a new value.
*/
if (class_exists('Swift_Preferences')) {
\Swift_Preferences::getInstance()->setTempDir(storage_path().'/tmp');
} else {
\Log::warning('Class Swift_Preferences does not exists');
}
}
Please make sure that the new “tmp” folder location is writable by the web server.

JApplicationCli Cronjob

I have the following script:
// Initialize Joomla framework
const _JEXEC = 1;
// Load system defines
if (file_exists(dirname(__DIR__) . '/defines.php'))
{
require_once dirname(__DIR__) . '/defines.php';
}
if (!defined('_JDEFINES'))
{
define('JPATH_BASE', dirname(__DIR__));
require_once JPATH_BASE . '/includes/defines.php';
}
// Get the framework.
require_once JPATH_LIBRARIES . '/import.legacy.php';
// Bootstrap the CMS libraries.
require_once JPATH_LIBRARIES . '/cms.php';
/**
* Cron job to trash expired cache data.
*
* #since 2.5
*/
class DoCron extends JApplicationCli
{
public function doExecute()
{
echo 'ok3';
$this->out('Fetching updates...');
}
}
JApplicationCli::getInstance('DoCron')->execute();
I have added this in CPanel with a Cronjob and get the results of excecution by e-mail.
Now I hoped for an e-mail with 'ok3' or 'Fetching updates...' but none of that all. I do get an e-mail but it is an reference to php excecution.
When I add an 'echo ok' tag right before:
JApplicationCli::getInstance('DoCron')->execute();
I get that 'ok' as a result in the e-mail.
Any thoughts on what goes wrong here? The script is based on general scripts coming with joomla 3.6.5. Those scripts also give no result.
I had the same problem. It turns out that the default php binary for most hosts is the PHP CGI. Running under PHP CGI results in no stdout, stderr and stdin which is why you are not seeing the correct output.
Instead, check your CPanel documentation and look for the CLI version of PHP. It is most likely called php-cli. For example, I had to run a cron job for a Joomla CLI app and found the following to work:
/usr/bin/php-cli /path/to/joomla/cli/my-cli -a b -c d --verbose

cron scheduler in laravel 4

I am trying to set cron for a command or controller action but it seemed to be not working for me. Please see below what I have tried
I have been trying to set up scheduler as per your instructions with no result.
When I try:
1. /usr/local/bin/php /home/mysite/public_html/protected/app/start/artisan cron:run it gives error
Could not open input file: /home/mysite/public_html/protected/app/start/artisan
2. /usr/local/bin/php /home/mysite/public_html/protected/app/controllers/TestController.php
it gives error Fatal error: Class 'BaseController' not found in
3. /usr/local/bin/php -q /home/mysite/public_html/protected/app/start/artisan cron:run
Error-Could not open input file:
4. php /var/www/com/mysite.com/artisan cron:run
Status: 404 Not Found No input file specified.
/usr/local/bin/php home/opendesk/public_html/protected/app/start/artisan.php and in artisan.php I do like Artisan::add(new CronRunCommand);
Error Fatal error: Class 'Artisan' not found
/usr/local/bin/php /home/opendesk/public_html/protected/app/start/artisan.php
when in artisan.php I change it to $artisan->add(new CronRunCommand);
Error Fatal error: Call to a member function add() on a non-object
None of it seems to work. I have been read many SO and google posts but cant find a solution to this. hoping to get some help here
At first. Task Scheduling not available in laravel 4, you need use newest version.
At second. What a path /home/mysite/public_html/protected/app/start/artisan? Can you show application folder structure?
However artisan its file in application root folder in default installation. For sample - my application placed in \var\www\myaplication then artisan placed in \var\www\myaplication\artisan. And i call this php \var\www\myaplication\artisan or better, change current dir to cd \var\www\myaplication and run php artisan.
At trith artisan cron can not prepare controller method. You need create a cron task in file App\Console\Kernel
<?php
namespace App\Console;
use DB;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* #var array
*/
protected $commands = [
\App\Console\Commands\Inspire::class,
];
/**
* Define the application's command schedule.
*
* #param \Illuminate\Console\Scheduling\Schedule $schedule
* #return void
*/
protected function schedule(Schedule $schedule)
{
$schedule->call(function () {
DB::table('recent_users')->delete();
})->daily();
}
}
For more details read documenation this very useful!

Is there a way to specify the installation location for composer? (PSR-4)

I'm using composer to install my package and I'm trying to install my bundle in a very specific location.
In short, I have my packages with the following namespace prefixes:
TeamXyz/AbcBundle
TeamXyz/AbcComponent
Now, since we have tons of components and bundles, we want to separate them into 2 folders like this:
vendor/TeamXyz/Component/AbcComponent
vendor/TeamXyz/Bundle/AbcBundle
It used to work very well but with PSR-4 I cannot seem to be able to control the location where my package should be installed. I wonder if I have to write custom package installer for composer to be able to do this?
Ok, I found out a way to do that, simply wrote my own custom package installer and voila.
<?php
/**
* Created by myTeam.
* Date: 6/11/14
* Time: 1:43 PM
* Question? Come to our website at http://my.com
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace My\PackageInstaller;
use Composer\Package\PackageInterface;
use Composer\Installer\LibraryInstaller;
class BundleInstaller extends LibraryInstaller
{
/**
* {#inheritDoc}
*/
public function getPackageBasePath(PackageInterface $package)
{
$prefix = substr($package->getPrettyName(), 0, 3);
if ('my/' !== $prefix) {
throw new \InvalidArgumentException(
'Unable to install package, my package '
. 'should always start their package name with '
. '"my/"'
);
}
$packageName = str_replace('my/', '', $package->getPrettyName());
return $this->vendorDir . '/my/Bundle/' . $packageName;
}
/**
* {#inheritDoc}
*/
public function supports($packageType)
{
return 'my-bundle' === $packageType;
}
}
And yes I understand everything you guys complain about, but a tool is a tool and one person can use it the best way that fits his need. At least that's what I believe :). Maybe I'm doing something stupid here for not using Composer the exact way it was meant to be used. But hey, if we are using all the tools the exact ways they were meant to be used, lots of innovation would have happened in the first place :)

Resources