Moving Laravel 5.3 project from Windows to Ubuntu - php

I recently moved my Laravel 5.3.1 (Repository pattern) project from Windows 10 to Ubuntu 16.04LTs. When I update the composer, I'm getting the following errors.
Illuminate\Foundation\ComposerScripts::postUpdate
PHP Warning: Uncaught ErrorException: require(/opt/lampp/htdocs/new-abc.test.lk): failed to open stream:
Success in
/opt/lampp/htdocs/new-abc.test.lk/vendor/composer/autoload_real.php:55
Stack trace:
#0 /opt/lampp/htdocs/new-abc.test.lk/vendor/composer/autoload_real.php(55):
Composer\Util\ErrorHandler::handle(2, 'require(/opt/la...',
'/opt/lampp/htdo...', 55, Array)
#1 /opt/lampp/htdocs/new-abc.test.lk/vendor/composer/autoload_real.php(55):
require()
#2 /opt/lampp/htdocs/new-abc.test.lk/vendor/composer/autoload_real.php(45):
composerRequirecf118caaa79186b36c4e6ab213835334('efaf82f485f314c...',
'/opt/lampp/htdo...')
#3 /opt/lampp/htdocs/new-abc.test.lk/vendor/autoload.php(7): ComposerAutoloaderInitcf118caaa79186b36c4e6ab213835334::getLoader()
#4 /opt/lampp/htdocs/new-abc.test.lk/vendor/laravel/framework/src/Illuminate/Foundation/ComposerScripts.php(30):
require_once('/opt/lampp/htdo...')
#5 /usr/share/php/Composer/EventDispatcher/EventDispatcher.php(238):
Illuminate\Foundation\Comp in
/opt/lampp/htdocs/new-abc.test.lk/vendor/composer/autoload_real.php on
line 55
Warning: Uncaught ErrorException: require(/opt/lampp/htdocs/new-abc.test.lk): failed to open stream:
Success in
/opt/lampp/htdocs/new-abc.test.lk/vendor/composer/autoload_real.php:55
Stack trace:
#0 /opt/lampp/htdocs/new-abc.test.lk/vendor/composer/autoload_real.php(55):
Composer\Util\ErrorHandler::handle(2, 'require(/opt/la...',
'/opt/lampp/htdo...', 55, Array)
#1 /opt/lampp/htdocs/new-abc.test.lk/vendor/composer/autoload_real.php(55):
require()
#2 /opt/lampp/htdocs/new-abc.test.lk/vendor/composer/autoload_real.php(45):
composerRequirecf118caaa79186b36c4e6ab213835334('efaf82f485f314c...',
'/opt/lampp/htdo...')
#3 /opt/lampp/htdocs/new-abc.test.lk/vendor/autoload.php(7): ComposerAutoloaderInitcf118caaa79186b36c4e6ab213835334::getLoader()
#4 /opt/lampp/htdocs/new-abc.test.lk/vendor/laravel/framework/src/Illuminate/Foundation/ComposerScripts.php(30):
require_once('/opt/lampp/htdo...')
#5 /usr/share/php/Composer/EventDispatcher/EventDispatcher.php(238):
Illuminate\Foundation\Comp in
/opt/lampp/htdocs/new-abc.test.lk/vendor/composer/autoload_real.php on
line 55
PHP Fatal error: composerRequirecf118caaa79186b36c4e6ab213835334(): Failed opening
required '/opt/lampp/htdocs/new-abc.test.lk/'
(include_path='.:/usr/share/php') in
/opt/lampp/htdocs/new-abc.test.lk/vendor/composer/autoload_real.php on
line 55
Fatal error: composerRequirecf118caaa79186b36c4e6ab213835334(): Failed opening required '/opt/lampp/htdocs/new-abc.test.lk/'
(include_path='.:/usr/share/php') in
/opt/lampp/htdocs/new-abc.test.lk/vendor/composer/autoload_real.php on
line 55
What I tried:
Removing the existing vendor folder
Removing the composer.lock file
Any help would be appreciated.

The problem was caused due to the case sensitive issue. I think windows have neglected but Linux didn't.
What I've done is, I've created a custom helper file and included in the composer.json.
The mistake was the actual filename case sensitive didn't match the included file in the composer.json.

Related

Copying existing site to LOCALHOST. Tried opening home page, Error: Failed to open stream: No such file or directory

Warning: require(/usr/share/php/wp-stack-cache.php): Failed to open stream: No such file or directory in C:\xampp\htdocs\model\public_html\wp-content\mu-plugins\wp-stack-cache.php on line 31
Fatal error: Uncaught Error: Failed opening required '/usr/share/php/wp-stack-cache.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\model\public_html\wp-content\mu-plugins\wp-stack-cache.php:31 Stack trace: #0 C:\xampp\htdocs\model\public_html\wp-settings.php(322): include_once() #1 C:\xampp\htdocs\model\public_html\wp-config.php(82): require_once('C:
xampp
htdocs...') #2 C:\xampp\htdocs\model\public_html\wp-load.php(37): require_once('C:
xampp
htdocs...') #3 C:\xampp\htdocs\model\public_html\wp-blog-header.php(13): require_once('C:
xampp
htdocs...') #4 C:\xampp\htdocs\model\public_html\index.php(17): require('C:
xampp
htdocs...') #5 {main} thrown in C:\xampp\htdocs\model\public_html\wp-content\mu-plugins\wp-stack-cache.php on line 31
There has been a critical error on this website.
Can anyone help me out?
I see you're trying to copy a WordPress website down to your localhost, I've had to do this from a Linux server not too long ago and found this plugin (https://en-ca.wordpress.org/plugins/all-in-one-wp-migration/) to be super helpful. Install it and export it to a file and then import it and it should clear up the majority of the problems you're having!

Composer can't find file on Linux

when I try
composer dump-autoload
I get the following error on my linux machine
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
PHP Warning: Uncaught ErrorException: require(/App/Helpers/AppHelper.php): failed to open stream: No such file or directory in /var/www/page/vendor/composer/autoload_real.php:66
Stack trace:
#0 /var/www/page/vendor/composer/autoload_real.php(66): Composer\Util\ErrorHandler::handle(2, 'require(/App/He...', '/var/www/pag...', 66, Array)
#1 /var/www/page/vendor/composer/autoload_real.php(66): require()
#2 /var/www/page/vendor/composer/autoload_real.php(56): composerRequire14063f7e5e06d46e1f9f9d444238e903('ba1c657daf90253...', '/App/Helpers/Ap...')
#3 /var/www/page/vendor/autoload.php(7): ComposerAutoloaderInit14063f7e5e06d46e1f9f9d444238e903::getLoader()
#4 /var/www/page/vendor/laravel/framework/src/Illuminate/Foundation/ComposerScripts.php(43): require_once('/var/www/pag...')
#5 phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php(292): Illuminate\Foundation\ComposerScripts::postAutoloadDump(Object(Composer\Script\Event))
#6 phar:///usr/local/bin/com in /var/www/page/vendor/composer/autoload_real.php on line 66
Warning: Uncaught ErrorException: require(/App/Helpers/AppHelper.php): failed to open stream: No such file or directory in /var/www/page/vendor/composer/autoload_real.php:66
Stack trace:
#0 /var/www/page/vendor/composer/autoload_real.php(66): Composer\Util\ErrorHandler::handle(2, 'require(/App/He...', '/var/www/pag...', 66, Array)
#1 /var/www/page/vendor/composer/autoload_real.php(66): require()
#2 /var/www/page/vendor/composer/autoload_real.php(56): composerRequire14063f7e5e06d46e1f9f9d444238e903('ba1c657daf90253...', '/App/Helpers/Ap...')
#3 /var/www/page/vendor/autoload.php(7): ComposerAutoloaderInit14063f7e5e06d46e1f9f9d444238e903::getLoader()
#4 /var/www/page/vendor/laravel/framework/src/Illuminate/Foundation/ComposerScripts.php(43): require_once('/var/www/pag...')
#5 phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php(292): Illuminate\Foundation\ComposerScripts::postAutoloadDump(Object(Composer\Script\Event))
#6 phar:///usr/local/bin/com in /var/www/page/vendor/composer/autoload_real.php on line 66
PHP Fatal error: composerRequire14063f7e5e06d46e1f9f9d444238e903(): Failed opening required '/App/Helpers/AppHelper.php' (include_path='.:/usr/share/php') in /var/www/page/vendor/composer/autoload_real.php on line 66
Fatal error: composerRequire14063f7e5e06d46e1f9f9d444238e903(): Failed opening required '/App/Helpers/AppHelper.php' (include_path='.:/usr/share/php') in /var/www/page/vendor/composer/autoload_real.php on line 66
But when I do it on my windows machine its working fine.
The files Im trying to include are
"files": [
"App/Helpers/AppHelper.php",
"App/Helpers/CoinHiveApi.php",
"App/Helpers/CloudflareAPI.php"
]
Is there anyting I have to add/change?
In laravel, You need to gives proper path(without any letter cases change) of file /Directive.
When you are work with composer.json, .env, any provider etc you need to run below command because laravel create cache itself.
1) composer update (If you add new package)
2) composer dump-autoload (Why do I have to run "composer dump-autoload" command to make migrations work in laravel?)
3) php artisan cache:clear
4) php artisan view:clear(if you add new view)
As mentioned in the comments, case matters.
Composer takes file paths:
"files": [
"app/Helpers/AppHelper.php",
...
]
App !== app
The folder is app.

Migrated WordPress Site and Now Theme Isn't Loading WordPress Functions

Just migrated a website from local machine to staging server.
Weirdly, the theme isn't loading the functions even though the stack trace looks correct:
[15-Dec-2017 00:22:51 UTC] PHP Fatal error: Uncaught Error: Call to undefined function of_get_option() in /var/www/html/assets/themes/underscore/header.php:37
Stack trace:
#0 /var/www/html/wp-includes/template.php(555): require_once()
#1 /var/www/html/wp-includes/template.php(514): load_template('/var/www/html/a...', true)
#2 /var/www/html/wp-includes/general-template.php(45): locate_template(Array, true)
#3 /var/www/html/assets/themes/underscore/index.php(1): get_header()
#4 /var/www/html/wp-includes/template-loader.php(75): include('/var/www/html/a...')
#5 /var/www/html/wp-blog-header.php(16): require_once('/var/www/html/w...')
#6 /var/www/html/index.php(17): require('/var/www/html/w...')
#7 {main}
thrown in /var/www/html/assets/themes/underscore/header.php on line 37
I am in a hurry so I have tried just copying a copy of the of _get_option function into the file which got rid of the error.
But then up popped another one in it's place.
[15-Dec-2017 00:29:35 UTC] PHP Warning: include_once(../wp-includes\option.php): failed to open stream: No such file or directory in /var/www/html/assets/themes/underscore/header.php on line 33
[15-Dec-2017 00:29:35 UTC] PHP Warning: include_once(): Failed opening '../wp-includes\option.php' for inclusion (include_path='.:/usr/share/php') in /var/www/html/assets/themes/underscore/header.php on line 33
[15-Dec-2017 00:29:35 UTC] PHP Fatal error: Uncaught Error: Call to undefined function WC() in /var/www/html/assets/themes/underscore/header.php:79
Stack trace:
#0 /var/www/html/wp-includes/template.php(555): require_once()
#1 /var/www/html/wp-includes/template.php(514): load_template('/var/www/html/a...', true)
#2 /var/www/html/wp-includes/general-template.php(45): locate_template(Array, true)
#3 /var/www/html/assets/themes/underscore/index.php(1): get_header()
#4 /var/www/html/wp-includes/template-loader.php(75): include('/var/www/html/a...')
#5 /var/www/html/wp-blog-header.php(16): require_once('/var/www/html/w...')
#6 /var/www/html/index.php(17): require('/var/www/html/w...')
#7 {main}
thrown in /var/www/html/assets/themes/underscore/header.php on line 79
Anyone got any clue why this is?
themes/underscore/header.php has an incorrect reference to another file, this looks likely to be a problem /wp-includes\option.php

Laravel Tinker: Class 'Psy\Exception\ErrorException' not found

I'm trying to run Laravel 5.5 tinker but get an exception when i try to run the factory Command. For example:
factory(App\Article::class, 100)->create();
When i try to run lets say the User:class command in another repository it works without any problems.
PHP error: Class 'Psy\Exception\ErrorException' not found in /Users/sebastian/Development/app.manager/vendor/psy/psysh/src/Psy/Shell.php on line 812
Extended Error-Message:
PHP warning: opendir(/Users/sebastian/Development/app.manager/database/factories): failed to open dir: Too many open files in /Users/sebastian/Development/app.manager/vendor/symfony/finder/Iterator/RecursiveDirectoryIterator.php on line 145
PHP Warning: Uncaught Psy\Exception\ErrorException: PHP warning: require(/Users/sebastian/Development/app.manager/database/factories/ArticleFactory.php): failed to open stream: Too many open files in /Users/sebastian/Development/app.manager/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Factory.php on line 202 in /Users/sebastian/Development/app.manager/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Factory.php:202
Stack trace:
#0 /Users/sebastian/Development/app.manager/vendor/psy/psysh/src/Psy/Shell.php(809): Psy\Exception\ErrorException::throwException(2, 'require(/Users/...', '/Users/sebastia...', 202)
#1 /Users/sebastian/Development/app.manager/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Factory.php(202): Psy\Shell->handleError(2, 'require(/Users/...', '/Users/sebastia...', 202, Array)
#2 /Users/sebastian/Development/app.manager/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Factory.php(202): require()
#3 /Users/sebastian/Development/app.manager/vendor/laravel/framework in /Users/sebastian/Development/app.manager/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Factory.php on line 202
PHP Fatal error: Illuminate\Database\Eloquent\Factory::load(): Failed opening required '/Users/sebastian/Development/app.manager/database/factories/ArticleFactory.php' (include_path='.:') in /Users/sebastian/Development/app.manager/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Factory.php on line 202
PHP Fatal error: Uncaught Psy\Exception\ErrorException: PHP warning: include(/Users/sebastian/Development/app.manager/vendor/symfony/debug/Exception/FatalErrorException.php): failed to open stream: Too many open files in /Users/sebastian/Development/app.manager/vendor/composer/ClassLoader.php on line 444 in /Users/sebastian/Development/app.manager/vendor/composer/ClassLoader.php:444
Stack trace:
#0 /Users/sebastian/Development/app.manager/vendor/psy/psysh/src/Psy/Shell.php(809): Psy\Exception\ErrorException::throwException(2, 'include(/Users/...', '/Users/sebastia...', 444)
#1 /Users/sebastian/Development/app.manager/vendor/composer/ClassLoader.php(444): Psy\Shell->handleError(2, 'include(/Users/...', '/Users/sebastia...', 444, Array)
#2 /Users/sebastian/Development/app.manager/vendor/composer/ClassLoader.php(444): include()
#3 /Users/sebastian/Development/app.manager/vendor/composer/ClassLoader.php(322): Composer\Autoload\includeFile('/Users/sebastia...')
#4 [internal function]: Composer\Autoload\ClassLoader->loadClass('Sym in /Users/sebastian/Development/app.manager/vendor/composer/ClassLoader.php on line 444
What I've alrdy tried:
removing and re-ading the laravel/tinker from composer.json

PHP Artisan Tinker not working with Laravel 5.4 and PHP 7.0.1

I just added tinker to my Laravel project 5.4.
When I try to run:
php artisan tinker
I am getting following error:
PHP Warning: Uncaught ErrorException: require(/home/abdullah/php_apps/website): failed to open stream: Success in /home/abdullah/php_apps/website/vendor/laravel/tinker/src/ClassAliasAutoloader.php:51
Stack trace:
#0 /home/abdullah/php_apps/website/vendor/laravel/tinker/src/ClassAliasAutoloader.php(51): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'require(/home/a...', '/home/abdullah/...', 51, Array)
#1 /home/abdullah/php_apps/website/vendor/laravel/tinker/src/ClassAliasAutoloader.php(51): require()
#2 /home/abdullah/php_apps/website/vendor/laravel/tinker/src/ClassAliasAutoloader.php(33): Laravel\Tinker\ClassAliasAutoloader->__construct(Object(Psy\Shell), '/home/abdullah/...')
#3 /home/abdullah/php_apps/website/vendor/laravel/tinker/src/Console/TinkerCommand.php(59): Laravel\Tinker\ClassAliasAutoloader::register(Object(Psy\Shell), '/home/abdullah/...')
#4 [internal function]: Laravel\Tinker\Console\TinkerCommand->handle()
#5 /home/abdullah/php_apps/website/vendor/laravel/framework/src/Illuminate/Contai in /home/abdullah/php_apps/website/vendor/laravel/tinker/src/ClassAliasAutoloader.php on line 51
PHP Fatal error: Laravel\Tinker\ClassAliasAutoloader::__construct(): Failed opening required '/home/abdullah/php_apps/website' (include_path='.:/home/abdullah/.phpbrew/php/php-7.0.1/lib/php') in /home/abdullah/php_apps/website/vendor/laravel/tinker/src/ClassAliasAutoloader.php on line 51
[Symfony\Component\Debug\Exception\FatalErrorException]
Laravel\Tinker\ClassAliasAutoloader::__construct(): Failed opening required '/home/abdullah/php_apps/website' (include_path='.:/home/abdullah/.phpbrew/php/php-7.0.1/lib/php')
I have tried giving rights to various folders.
Also tried adding the Tinker class to console/kernel.php.
I fixed it finally by upgrading my version of laravel.
Laravel v5.4.0 to Laravel v5.4.33.

Categories