laravel 5 development.ERROR - php

Im getting this error randomly,i search it and it seems that this happens if you havent set an app key,the problem is i had set it from the start.The problem usually happens when i make multiple $http calls from my app it never happens from postman.
error:
[2015-10-12 16:36:11] development.ERROR: exception 'RuntimeException' with message 'No supported encrypter found. The cipher and / or key length are invalid.' in C:\xampp2\laravel\vendor\laravel\framework\src\Illuminate\Encryption\EncryptionServiceProvider.php:29 Stack trace:
0 C:\xampp2\laravel\vendor\laravel\framework\src\Illuminate\Container\Container.php(733): Illuminate\Encryption\EncryptionServiceProvider->Illuminate\Encryption{closure}(Object(Illuminate\Foundation\Application), Array)
1 C:\xampp2\laravel\vendor\laravel\framework\src\Illuminate\Container\Container.php(626): Illuminate\Container\Container->build(Object(Closure), Array)
2 C:\xampp2\laravel\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(674): Illuminate\Container\Container->make('encrypter', Array)
3 C:\xampp2\laravel\vendor\laravel\framework\src\Illuminate\Container\Container.php(837): Illuminate\Foundation\Application->make('Illuminate\Cont...')
4 C:\xampp2\laravel\vendor\laravel\framework\src\Illuminate\Container\Container.php(800): Illuminate\Container\Container->resolveClass(Object(ReflectionParameter))
5 C:\xampp2\laravel\vendor\laravel\framework\src\Illuminate\Container\Container.php(771): Illuminate\Container\Container->getDependencies(Array, Array)
6 C:\xampp2\laravel\vendor\laravel\framework\src\Illuminate\Container\Container.php(626): Illuminate\Container\Container->build('App\Http\Middle...', Array)
7 C:\xampp2\laravel\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(674): Illuminate\Container\Container->make('App\Http\Middle...', Array)
8 C:\xampp2\laravel\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(142): Illuminate\Foundation\Application->make('App\Http\Middle...')
9 C:\xampp2\htdocs\public\index.php(58): Illuminate\Foundation\Http\Kernel->terminate(Object(Illuminate\Http\Request), Object(Illuminate\Http\Response))
10 {main}
update:
ok i checked it a little more and if change the app.php
'key' => env('APP_KEY', 'someRandomString')
with my key
'key' => env('APP_KEY', 'My key')
im getting error 404 not found on the route.I think that at some point randomly fails to read the env key.It may be a problem with my resources im developing on my computer i will upload it to a server and check it again.

You should change it in your .env file, when you change the someRandomString in the env() call all you're doing is telling Laravel to use that as a default if it can't find the real app key. So Laravel is probably finding an incorrect app key and never gets to your default.
If you don't have a .env file (but you probably do, since your default failed), you should have a .env.example file that you can rename. Then you can do php artisan key:generate to generate and set it automatically.
If it still doesn't work after doing that, you have some other problem unrelated to app keys. :) Good luck!

OK i solved it the problem was my computer resources was not enough to make multiple calls after i upload to server everything works fine.

Related

Missing/broken image after migration for Cake PHP

I'm maintaining to exist project which migrated from another host.
I'm facing this issue where the image from app/media/tf/img/ are broken whereas from other path are working fine. Below are stack trace from error.log
2020-12-04 16:44:47 Error: [MissingControllerException] Controller class TransferController could not be found.
Exception Attributes: array (
'class' => 'TransferController',
'plugin' => 'Media',
)
Request URL: /xy/media/tf/img/123.jpg
Stack Trace:
#0 E:\www\xy\xy\app\webroot\index.php(92): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))
#1 E:\www\xy\xy\index.php(41): require('E:\\www\\xy...')
#2 {main}
Actually, from old server everything's are working fine using the exact same source code. Also, I did tried for the same workaround here but still not working.Glad if someone could help as I'm new to CakePHP.
UPDATE
Just tried to change the path app/img , it is working. It's kind of weird since media/transfer/img are in the same webroot.
img--> tried direct path(app/img/..), working
media--> tried /transfer/img/.. path, not working
manual--> tried direct path(app/manual/..), also not working
But still I need to use the media path and if any explanation for this would be highly appreciated.
Check imageBaseUrl in app.php , here we assign the folder for
$this->Html->image();

Get original path and filename of hashed name in Laravel view

I have a Laravel application in production server that produces exception when rendering the view. The log file printed stacktraces about where the exception happened, but with hashed name of view.
How do I get the original path and the filename of hashed view? Since I can only debug from the error log in the server. For example with this stacktrace, I want to find the original file path and name of 698a6499f344ea0485830fd76f437b7ae1833431.php
ErrorException: Undefined property: stdClass::$balance_perdana in /var/app/current/storage/framework/views/698a6499f344ea0485830fd76f437b7ae1833431.php:44
Stack trace:
#0 /var/app/current/storage/framework/views/698a6499f344ea0485830fd76f437b7ae1833431.php(44): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError(8, 'Undefined prope...', '/var/app/curren...', 44, Array)
#1 /var/app/current/vendor/laravel/framework/src/Illuminate/View/Engines/PhpEngine.php(42): include('/var/app/curren...')
There are solution that uses laravel debugbar (https://github.com/barryvdh/laravel-debugbar) to help find the related view, but I think this is not a good practice, activate debug mode in production environment.
Laravel stores compiled version file to speed up system execution.
Once your file is compiled and if you do not make changes into it then laravel direct executes this compiled version and this is how laravel executes fast process work.
So, displaying original name of file is not feasible.
Now for the solution, you can comment out your blade file name with <!-- BLADEFILENAME--> into particular file. So while facing any error then you can understand that which file is this.
Review Reference: Laravel blade debug view name on error

Laravel FatalErrorException in Handler.php line 25

I'm getting the following error on random occasions, working on a Laravel 5.1 project on the latest homestead with PHP7
FatalErrorException in Handler.php line 25:
Uncaught TypeError: Argument 1 passed to App\Exceptions\Handler::report() must be an instance of Exception, instance of TypeError given, called in /home/vagrant/Code/henau/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php on line 73 and defined in /home/vagrant/Code/henau/app/Exceptions/Handler.php:25
Stack trace:
#0 /home/vagrant/Code/henau/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(73): App\Exceptions\Handler->report(Object(TypeError))
#1 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleException(Object(TypeError))
#2 {main}
thrown
Even when I undo work that has been causing it, It stays. It's being caused by this block of code in this instance
\Mail::send('emails.registered', $user, function ($m) {
$m->to('miguel#dummyaddress.com')->subject('New Order');
});
It seems to me the error is not directly code-related. I've seen other people encounter it in complete different situations. And i've seen it popup in older threads regarding Homestead and PHP7. There was an askubuntu thread but it's offline, So I hope we can reopen the discussion here.
Solution
This is actually an error that an exception can't be shown. This is caused by using PHP7.x on an older Laravel project that requires PHP5.6.x
My solution was to create a new Homestead specific for this project and install php5.6 on that homestead using an older version of laravel/homestead
I had the same problem when running seeders Notflip . I'm usign Laravel framework 5.0.34. I had this structure:
App/Models/Users/ (My users's Models here)
After moving my users's models to the App directory, my seeder problem was solved.
Check your namespaces and put under consideration your Laravel Framework version before make changes in the framework.
Hope it helps!
This situation occur when laravel project version not compatible or not configured with your local installed version So the laravel not tracking the exact error and instead of showing exact error on line shows that type of errors
i had same problem in laravel 5.1. After reading this issue, i found out i was using laravel v5.1.0 and that seemed wrong so changed 5.1.0 to 5.1.* and ran composer update. this solved the issue for me.

Soundcloud API Upload suddenly throwing code 422

Been using the PHP Soundcloud API for some time now, and it's been working fine. The code I use to create the track array is (and has always been):
$track = json_decode($client->post('tracks', array(
'track[title]' => $title,
'track[asset_data]' => $filename,
'track[description]' => $desc,
'track[genre]' => "Podcast",
'track[artwork_data]' => $image
)));
And it's always been working just fine - until this morning, when I got this error message when uploading a track using my home-made PHP tool:
Fatal error: Uncaught exception 'Services_Soundcloud_Invalid_Http_Response_Code_Exception' with message 'The requested URL responded with HTTP code 422.' in /home/csicon/public_html/PodcastAuthor/lib/Soundcloud.php:943 Stack trace: #0 /home/csicon/public_html/PodcastAuthor/lib/Soundcloud.php(621): Services_Soundcloud->_request('https://api.sou...', Array) #1 /home/csicon/public_html/PodcastAuthor/2-publish.php(52): Services_Soundcloud->post('tracks', Array) #2 {main} thrown in /home/csicon/public_html/PodcastAuthor/lib/Soundcloud.php on line 943
Now, I'm no newb, and know what HTTP code 422 is all about, so I checked the contents of $title, $filename, $desc and $image. They are, in order:
Geekdays #274: 2015-11-17
#/home/csicon/public_html/PodcastAuthor/uploads/g274.mp3
Snowden, the FBI and the Oxford Dictionary are getting blamed for things that they may or may not have done. Also; the air you're breathing might be killing you. This, and so much more, on today's episode of Geekdays.
#/home/csicon/public_html/wp-content/uploads/2014/10/geekdays-600x600.png
All paths (to the mp3 and the image) check out, there's nothing wonky in the character set being used, and it's all worked before. What might have happened here? I'm stumped.
UPDATE! Turns out my webhost has upgraded their PHP environment from 5.4 to 5.6, and this is what broke it. What's changed between 5.4 and 5.6 that might have caused this, in that case?
Turns out my webhost has upgraded their PHP environment from 5.4 to 5.6, and this is what broke it. What's changed between 5.4 and 5.6 that might have caused this, in that case?
How cURL file uploads are handled has changed.
CURLOPT_SAFE_UPLOAD is set to true by default from PHP 5.6 on, and that means file uploads are not possible any more using the #-file path syntax, but CURLFile should be used for file uploads instead.
Try setting CURLOPT_SAFE_UPLOAD to false, using the setCurlOptions method.
Magically started working when I changed to the sebdesign/php-soundcloud version of the curl-file branch. Not sure why the "normal" curl-file branch didn't work, however.

Couchbase PHP SDK gives generic network error

I am running a website with 2 servers for website code (in PHP), and 1 server as load-balancer. All 3 are also running couchbase instances, as part of one single cluster.
In PHP code, I using couchbase buckets as follows:
$cluster = new \CouchbaseCluster('http://127.0.0.1:8091');
$greyloftWebbucket = $cluster->openBucket('some_bucket');
$query = \CouchbaseViewQuery::from('abcd', 'pqrs');
This arrangement works fine when all couchbase instances are running. When any one of them is closed and I try to access buckets, I get following error randomly:
[2015-07-17 13:46:08] production.ERROR: exception 'CouchbaseException' with message 'Generic network failure. Enable detailed error codes (via LCB_CNTL_DETAILED_ERRCODES, or via `detailed_errcodes` in the connection string) and/or enable logging to get more information' in [CouchbaseNative]/CouchbaseBucket.class.php:282
Stack trace:
#0 [CouchbaseNative]/CouchbaseBucket.class.php(282): _CouchbaseBucket->http_request(1, 1, '/_design/abcd...', NULL, 1)
#1 [CouchbaseNative]/CouchbaseBucket.class.php(341): CouchbaseBucket->_view(Object(_CouchbaseDefaultViewQuery))
#2 /var/www/greyloft-laravel/app/couchbasemodel.php(25): CouchbaseBucket->query(Object(_CouchbaseDefaultViewQuery))
#3 /var/www/greyloft-laravel/app/Http/Controllers/Listing.php(42): App\couchbasemodel::listings()
#4 [internal function]: App\Http\Controllers\Listing->index()
That is, one time the page will load correctly and show bucket content, and then one time will show me above error. It doesn't matter if I access load balancer or any of the server directly.
Also, autofailover in enabled with replication set to 1 in couchbase cluster. In all 3 servers, I have set LCB_LOGLEVEL=5
What is happening? Is it problem in Couchbase PHP SDK or anything else? I would appreciate any help at all.
Update:
As per mnunberg's suggestion, I'm using new connection string
$cluster = new \CouchbaseCluster('http://127.0.0.1:8091?detailed_errcodes=1');
With this, the error message is now. It still pops over randomly (around half the times):
CouchbaseException in CouchbaseBucket.class.php line 74: The remote host refused the connection. Is the service up?
The autofailover is taking place. In Couchbase console log:
Failed over 'ns_1#<ip_address>': ok
Node ('ns_1#<ip_address>') was automatically failovered.
It seems to me that SDK is still trying to read the failed over node. Why is this happening? Any possible solution?

Categories