amirkamizi

Member Since 3 Months Ago

Experience Points
13,530
Total
Experience

1,470 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
110
Lessons
Completed
Best Reply Awards
1
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

  • Community Pillar

    Earned once your experience points ranks in the top 10 of all Laracasts users.

Level 3
13,530 XP
Jun
09
4 days ago
Activity icon

Replied to Fetch Single Row In Laravel

when you use get() you will get a collection and for collection, it is possible to loop through each collection. but when you call first() you are getting one model. and you cannot loop through a model.

let me give you an example with simple arrays.

imagine collection as arrays

$exampleArray = [1,2,3,4];

when you use get() you get something like this and you can loop through it. but

$exampleNumber = 1;

when you call first() you are getting something like this. you cannot loop through it.

Jun
08
5 days ago
Activity icon

Replied to Call To A Member Function Create() On Null

before doing

$setting->image->create([
                'filename' => $file->getClientOriginalName(),
                'path' => $file->store('images/logo', 'myDriver')
            ]);

first check if setting has image. if there is no relationship it is returning null and then you are calling null->create and that is causing the error

Activity icon

Replied to Fetch Single Row In Laravel

this is caused because of:

1- as @jlrdw mentioned change 'flights' to 'flight'.

2- there is no record where last name is Gibson. in that case you will get null. and then you are trying to get null->name which is causing the error.

Activity icon

Replied to Keep Getting File Get Content Error (updated)

I've updated the question.

Jun
01
1 week ago
Activity icon

Replied to New To Testing: 2 Questions

I'm glad I could help.

May
31
1 week ago
Activity icon

Replied to Why Model Of New Created Row Has Created_at == Null?

why did you use public $timestamps = false;

exactly as @MichalOravec said.

Activity icon

Replied to New To Testing: 2 Questions

that is possible. OR you could create a test live server for your microservices as well. if the microservice is working properly and has passed all its own tests, then I would deploy it on a test server as well.

that way even if another developer or program wanted to use that microservice they can also use the test server.

for example for many websites that offer b2b services, they have 2 APIs. one is for test-example.com/api and the other is for example.com/api

that way you as another developer or another business who wants to work with them, can develop your API and program and make as many tests as you want. if it's a shop you can shop and many weeks later search for your purchase with that code and still would work.

I personally like this type rather than cleaning the database in case it's testing, for 2 reasons:

1- my personal taste (you could do whatever you prefer)

2- we are humans and we make mistakes. imagine if you want to send a test but you don't add it in your header and the microservice doesn't know it's a test so it would add data to the live database.

I hope I could explain properly.

Activity icon

Replied to Datatype Mismatch Using Eloquent Model

I would set a default value for my db column.

also could you please try adding to db by doing new User() rather than user::create()

$user = new User();
$user->name ='Laravel user';
$user->password='password';
$user->is_suspended=0;
$user->save()
Activity icon

Awarded Best Reply on New To Testing: 2 Questions

with the first question, I had the same thing. there are multiple things you can do:

a: create and delete as you said

b: what kind of information those microservices create? you create them yourself rather than sending them to microservices. then the refreshdatabase would work (Only do this if you are sure that the other tests cover the microservice itself, and it sends and receives data correctly)

c: in php unit you can create a test database. in the testing tutorials on laracast you can see how it works.

with the second question, in depends on you and your project. in my opinion it's always a good idea to test it on a testing server at least. if you can test it on the live server then even better. it's just my opinion.

Activity icon

Replied to New To Testing: 2 Questions

with the first question, I had the same thing. there are multiple things you can do:

a: create and delete as you said

b: what kind of information those microservices create? you create them yourself rather than sending them to microservices. then the refreshdatabase would work (Only do this if you are sure that the other tests cover the microservice itself, and it sends and receives data correctly)

c: in php unit you can create a test database. in the testing tutorials on laracast you can see how it works.

with the second question, in depends on you and your project. in my opinion it's always a good idea to test it on a testing server at least. if you can test it on the live server then even better. it's just my opinion.

Activity icon

Replied to Datatype Mismatch Using Eloquent Model

see if this one works

 'is_suspended' => 0,
May
29
2 weeks ago
Activity icon

Replied to Cannot Declare Class Because The Name Is Already In Use?

okay now it's weird that it's happening again with the new class because apparently, what you do is trying to create the class again but when migrating it shouldn't create the class again it should only create the table.

I don't know what your code is but if i had this issue it's I would

1-

php artisan optimize:clear
composer dump-autoload
composer clear-cache

2- change the name from CreateReceiptsSecondTable to CreateReceiptsThirdTable to see what is my error ( probably the error would change)

3- migrate:fresh and if I get the

Cannot declare class CreateReceiptsThirdTable, because the name is already in use

then there is something else. it's not with the migration file only. it's probably your migration is not happening correctly.

in that case, I would know that "okay the issue is not just the class name as the error says".

if your problem is solved and by step 3 you don't get the error, perfect but even if you do, at least you're making some progress and debug the right place.

Activity icon

Replied to Cannot Declare Class Because The Name Is Already In Use?

the error changed. that's a good sign. now it says the table already exists. I think you should migrate:fresh. so it would delete the tables. it wants to create the table but the table is already in the database.

Activity icon

Replied to Cannot Declare Class Because The Name Is Already In Use?

have you tried changing the class name to something else? I mean if instead of

class CreateReceiptsTable extends Migration

you write

class CreateReceiptsSecondTable extends Migration

what happens?

Activity icon

Replied to Permission Denied For Daily Logs In Laravel

thank you very much for your explanation

Activity icon

Replied to Permission Denied For Daily Logs In Laravel

in the cron, I only added the laravel schedule. You mean that is causing this?

Activity icon

Started a new Conversation Permission Denied For Daily Logs In Laravel

recently I changed the logs from single to daily.

'mlog' => [
            'driver' => 'daily',
            'path' => storage_path('logs/mlog.log'),
            'level' => 'debug',
        ],

and noticed that for logs for the new day I get this error

The stream or file "/path_to_laravel_project/storage/logs/mlog-2021-05-29.log" could not be opened in append mode: failed to open stream: Permission denied"
  #code: 0
  #file: "/path_to_laravel_project/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php"
  #line: 111

log files are by default 644 and when I change them to 777 it's fixed.

but why this happens? and how can I make the default mode for new logs to be 777 or 775 so I wouldn't get this error everyday?

May
28
2 weeks ago
Activity icon

Replied to Laravel Update Query (Add A Value To Existing A Value)

$pay->paying = $request->paying += 500;

every time you refresh the page the $request->paying is back to the initial value. you should add the +500 to the $pay->paying

$oldPaying = $pay->paying;
$pay->paying = $oldPaying + 500;

Or take a look at the link that @sr57 sent. laravel has increment and decrement on models which you can use.

May
27
2 weeks ago
Activity icon

Replied to Laravel Image Not Showing On Production

have you solved it yet?

if not then I found the files for one of my old projects. this is how I did it and it was working:

in the routes:

Route::get('/images/{id}', '[email protected]')->name('image_show');

in the controller

public function show(Request $request,$id){
$photo = \App\Image::where('id',$id)
                            ->first();
 return response()->file(storage_path('app/images/'.$photo->file_name));
}

file system in config

'public' => [
            'driver' => 'local',
            'root' => storage_path('app/public'),
            'url' => env('APP_URL').'/storage',
            'visibility' => 'public',
        ],

in the storage folder inside app I have 2 folders

  • public
  • images
Activity icon

Replied to Laravel Image Not Showing On Production

I didn't mean the route name. sorry if I didn't explain clearly. I mean since your route starts with storage/image_path and there is a folder in the server named "storage", sometimes it causes this kindof issues. if your URL was something like /exmaple_url/image_path I think the issue might get resolved.

May
26
2 weeks ago
Activity icon

Replied to Laravel Image Not Showing On Production

first of all what does $data->image print?

I think I had a similar issue in a project. for images when your route name is the same name as a folder that exists in your server this happens. so for files rather than checking the file URL tries to get files from that folder.

honestly, I didn't know about this thing until I changed my routes to something else and it started to work. I don't know why is that but maybe you're facing the same issue. change the route to something that doesn't have a folder with similar name on the server.

May
23
3 weeks ago
Activity icon

Replied to 3rd Party API Service Class

yes, but before returning the content also check if the response is successful. https://laravel.com/docs/8.x/http-client#making-requests

May
22
3 weeks ago
Activity icon

Replied to PHP Optimization

rather than calling for loop 4 times, you could call while. OR even better, create a function and then go through the process recursively.

May
20
3 weeks ago
Activity icon

Replied to PhpStorm Laravel(phpunit) 7 Print Variable To Console

in the same file when I make changes there is no issue. but when I create a new test with php artisan make:test I should clear the config otherwise it doesn't load the test. I have no idea why

Activity icon

Replied to PhpStorm Laravel(phpunit) 7 Print Variable To Console

is it possible to run php artisan config cahce in setup of the test?

Activity icon

Replied to PhpStorm Laravel(phpunit) 7 Print Variable To Console

yes I double checked it. I don't know why but before each test I should run php artisan config:cache

Activity icon

Started a new Conversation PhpStorm Laravel(phpunit) 7 Print Variable To Console

How can i print a variable to console in laravel testing?

public function testExample()
    {
        dd('here');
        $response = $this->get('/');

        $response->assertStatus(200);
    }

this prints

PHPUnit 8.5.8 by Sebastian Bergmann and contributors.



Time: 518 ms, Memory: 22.00 MB

OK (2 tests, 2 assertions)
Process finished with exit code 0
May
18
3 weeks ago
Activity icon

Replied to Intelephense Undefined Method And Undefined Type

unfortunatly that's true. I got phpstorm instead.

Activity icon

Replied to Undefined Method 'documentations'.intelephense(1013)

I got phpstorm instead :)

Activity icon

Replied to Undefined Method 'documentations'.intelephense(1013)

I could not solve it so I got phpstorm.

Activity icon

Replied to Undefined Method 'documentations'.intelephense(1013)

yeah. finally i did this one. I got phpstorm :)

May
16
4 weeks ago
Activity icon

Started a new Conversation Intelephense Undefined Method And Undefined Type

with intelephense there is an issue with undefined type and undefined method. my file runs and has no bugs or no errors but after I installed intelephense when I open it with vscode and with the intelephense extention it gave me 49 problems

for example for

$user = Auth::user();

I do have use Auth; in my file.

the error intelephense gives me is

Undefined type 'Auth'.intelephense(1009)
View Problem (Alt+F8)
No quick fixes available

what should I do? it's annoying to see red lines all over the file

Activity icon

Replied to Undefined Method 'documentations'.intelephense(1013)

did you find a solution for this?

May
15
4 weeks ago
Activity icon

Commented on PHP Automatic Imports

with intelephense there is an issue with undefined type and undefined method. my file had no issue on the server but when I open it with vscode and with the intelephense extention it gave me 49 problems

for example for

$user = Auth::user();

I do have use Auth; in my file.

the error intelephense gives me is

Undefined type 'Auth'.intelephense(1009)
View Problem (Alt+F8)
No quick fixes available

what should I do?

Activity icon

Commented on Determine The Average Rentals Per Day

thank you very much for this Great Course.

I wish you had included more advanced topics like procedures and partitioning as well.

May
14
4 weeks ago
Activity icon

Replied to Clustering And Improving The Speed Of Jobs

@tray2 oh i understand now. I don't know if mysql can do that I should check it. that could also be a good idea. thank you very much

Activity icon

Replied to Clustering And Improving The Speed Of Jobs

@tray2 I cannot thank you enough for the time and your explanation and amazing reference links.

regarding the second point you mentioned unfortunately I couldn't understand quitely what you mean. did you mean I should write the json and xml to a file rather than parsing it to db, and in queries I then load the file? did I understand correcly?

Activity icon

Replied to Clustering And Improving The Speed Of Jobs

@tray2 first of all thank you very much for your time and reponse.

Each product has a user that offers it. Some of the users update their rates on our website. But for the others(which are the majority) we should pull the prices and other information from them. For most of our users they allow up to 10 products in one api call.

These products have different prices in different days. So for example if we want to get the prices for 10 products for 30 days we should send 30 requests to that supplier and each request containing 10 products. If there were 20 products then we had to send 60 requests to that supplier for 30 days.

Then after we get the response of that request, for each product a new job will dispatch that would go and update the price of that product for that specific date.

Now imagine 100k products and for 90 days.

Some other notes:

  • if a job for updating price and date does 2 product for 1 date or 2 dates 1 product it takes twice as 1 product 1 date. That's why i didn't batch them together.

  • the prices needs to get updated constantly rather than every 10 days.

Regarding your Notes:

  • Make sure you have indexes on the columns that needs it: All the databases and all the columns that are getting constant query are indexed.

  • Don't pull more data than you need from tha database: recently I have changed that as well. and this with indexing increased the speed to almost half the time before.

  • Don't pull records from the database and loop over then in php if it can be avoided (Most likely it can): each product gets called alone when it's going to be updated. but for loops we have to loop through the products list (json or xml) that we get from our users.

  • Take a look at database transactions since it might help speed things up: yes and that actually is causing the lock problem. from getting the product to updating the rate used to be in one transaction. but now only the updating rate is in transaction

DB::beginTransaction();
try {
    for ($i=$from_date; $i < $to_date; $i++) { 
        $curDay = DB::table('calendar_dates')->select('id','full_date')->find($i);
        $inventory = DB::connection('mysqlProduct')->table('inventories')->updateOrInsert(
            ['calendar_date_id' => $curDay->id],
            ['count'=> $product->inventory,
            'no_inventory'=> $no_inventory]
        );
        $rate = DB::connection('mysqlProduct')->table('rates')->updateOrInsert(
            ['calendar_date_id' => $curDay->id],
            ['amount'=> $priceArray[$i - $from_date],'user_custom_price_id' =>$customIdsArray[$i - $from_date]]
        );  
    }
    DB::commit();
} catch (\Throwable $th) {
    DB::rollback();
    self::$message = $th;
}

and I get this error sometimes

SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction 
  • Look into partioning of parts of the database: i don't know what that is. could you please explain how it can help?

  • Move some of the logic from php into the database as stored procedures/functions or even database packages: oh I never thought of this one. does it really help? since rates and dates have different variables constantly wouldn't it make it longer that what already laravel does?

  • Move complex queries into database views it might help increase performance together with the proper indexes: for this jobs there are not a lot of complex queries it's just get and insert or update.

I would be grateful if you could share with me your opinion.

thank you very much

Activity icon

Replied to Display The Amount Of Employee Leave Per Month

first of all you should share more codes and details about your project in order to get better help

but as far as I could understand from your description

a command(i think it's the same as employees right?) has any leaves

then if you have defined the relationship correctly in laravel, you can query something like

$command = \App\Command::find(id_of_the_emplyee)

$command->leaves->count()

also check the documentation

https://laravel.com/docs/7.x/eloquent-relationships#counting-related-models

Activity icon

Started a new Conversation Clustering And Improving The Speed Of Jobs

our laravel project needs to update information constatnly from differnt users. we have written jobs that 1- get the information 2- dispatch other jobs to update the information

if we run the current project there would be 18000 jobs and they would cause 300000 jobs to dispatch.

each jobs takes 1 minute to finish

current configuration is to run 20 jobs at the same time.

so in order to finish all the jobs it takes (318000 / 20 / 60 / 24) 11 days.

and because this jobs need to run in loop we need to make it much faster (finish in less than a day)

I've been looking for solutions to increase the speed (clustering, multiple servers etc).

1- is it possible to achieve the resault we want? 2- if yes, what are the solutions?

project is in laravel 7 php 7.3 mysql 8.

the specs of our current server: Processor: Intel Xeon D-2141 I Memory: 16 GB DDR4 Disk: 500 GB (RAID1) Data Transfer: 5 TB IP addresses: 2

Apr
14
1 month ago
Activity icon

Replied to In Schedule Call Or In A Seperate Job

@neilstee Thank you very much for your explanation.

Apr
13
2 months ago
Activity icon

Started a new Conversation In Schedule Call Or In A Seperate Job

Hello

I have a task I need to run every 4 hours

here is the code

$schedule->call(function () {
    try {
        set_time_limit(30000);
        $timeStart = microtime(true);
        Log::notice('started sending jobs at ' . date("Y-m-d h:i:sa"));
        $products = \App\Product::where('get_info',true)->get();
        $getInfoDays = 30;
        $today = \App\CalendarDate::where('full_date',today()->format('Y-m-d'))->first();
        $jobCount = 0;
        for ($i=$today->id; $i <$today->id + $getInfoDays ; $i++) {
            foreach ($products as $product) {
                $limit = 5;
                $offset = 0;
                $suppliers = $product->suppliersList();
                $suppliersSub = $suppliers->skip($offset)->take($limit);
                $suppliersCount = $suppliersSub->count();
                while($suppliersCount > 0) {
                    $productSupplierCode = implode('*',$suppliersSub->toArray());
                    // \App\Jobs\GetSupplierInfo::dispatch($productSupplierCode,$product,$i);
                    try {                                  
                        $xml = \App\Supplier\Xml::formatXml($productSupplierCode);
                        $jobCount++;
                        if(!\App\Supplier\Curl::getInfo($xml)){
                            Log::critical('couldn not get info : '  . \App\Supplier\Curl::getMessage());
                        }else{
                            $xmlResponse = \App\Supplier\Curl::getResponse();
                            if(!\App\Supplier\Update::updateInfo($xmlResponse)){
                                Log::critical('couldn not update info : '  . \App\Supplier\Update::getMessage());
                            }
                        }
                        $timeEnd = microtime(true);
                        $executionTime = ($timeEnd - $timeStart);
                        Log::notice('has finished the supplier job in '.$executionTime . ' seconds');
                    } catch (\Throwable $th) {
                        Log::critical('could not execute the current job becuase of the following error');
                        Log::critical($th);
                    }
                    
                    $offset = $offset + $limit;
                    $suppliersSub = $suppliers->skip($offset)->take($limit);
                    $suppliersCount = $suppliersSub->count();
                }
            }
        }
        Log::notice("sent $jobCount jobs");
        $timeEnd = microtime(true);
        $executionTime = ($timeEnd - $timeStart);
        Log::notice('sent the jobs for all the countries in '.$executionTime . ' seconds');
    } catch (\Throwable $th) {
        Log::critical('could not execute the jobs becuase of the following error');
        Log::critical($th);
    }
})->name('get_info_updated03')->everyFourHours()->withoutOverlapping()->runInBackground();

it gets the products. then get their suppliers. then for each supplier it gets the information from that supplier and then updates my database.

for 50 produts and 30 days it would be 1500 iterations. each iteration takes around 50 seconds ( there are much more products like 1000+).

if I keep it in this manner in the schedule call, the schedule would be runnning for a long time. but if I seperate it in jobs each job would take 50 seconds but there would be many jobs.

which one would be better in terms of server resources? keeping it in the schedule call Or as jobs?

Activity icon

Awarded Best Reply on Predis Connection Refused

Redis had stopped working. I had to restart it. and run horizon again. then everything was back to normal. if you have this problem if you restart redis, it will be solved.

Activity icon

Replied to Predis Connection Refused

Redis had stopped working. I had to restart it. and run horizon again. then everything was back to normal. if you have this problem if you restart redis, it will be solved.

Apr
06
2 months ago
Activity icon

Started a new Conversation Predis Connection Refused

using laravel 7. updated the php from 7.1 to 7.2 and now keep getting this error for the jobs

production.ERROR: Connection refused [tcp://127.0.0.1:6379] {"exception":"[object] (Predis\Connection\ConnectionException(code: 111): Connection refused [tcp://127.0.0.1:6379] at /home/websiteroot/website/vendor/predis/predis/src/Connection/AbstractConnection.php:155)

server is centos 7 using WHM panel redis is installed predis is also installed with on whm extention installer

before the update everything was working fine

in the .env file

QUEUE_CONNECTION=redis

REDIS_CLIENT=predis
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

in horizon config

'production' => [
            'supervisor-1' => [
                'connection' => 'redis',
                'queue' => ['default'],
                'balance' => 'simple',
                'processes' => 10,
                'tries' => 3,
                'timeout' => 1200,
            ],
        ],

in the queue config

'redis' => [
            'driver' => 'redis',
            'connection' => 'default',
            'queue' => env('REDIS_QUEUE', 'default'),
            'retry_after' => 900,
            'block_for' => null,
        ],

the job that is run in console/kernel

$schedule->call(function () {
            \App\Jobs\OrderChecked::dispatch();
        })->everyMinute();

and this is the stack

production.ERROR: Connection refused [tcp://127.0.0.1:6379] {"exception":"[object] (Predis\Connection\ConnectionException(code: 111): Connection refused [tcp://127.0.0.1:6379] at /home/websiteroot/website/vendor/predis/predis/src/Connection/AbstractConnection.php:155)
[stacktrace]
#0 /home/websiteroot/website/vendor/predis/predis/src/Connection/StreamConnection.php(128): Predis\Connection\AbstractConnection->onConnectionError('Connection refu...', 111)
#1 /home/websiteroot/website/vendor/predis/predis/src/Connection/StreamConnection.php(178): Predis\Connection\StreamConnection->createStreamSocket(Object(Predis\Connection\Parameters), 'tcp://127.0.0.1...', 4)
#2 /home/websiteroot/website/vendor/predis/predis/src/Connection/StreamConnection.php(100): Predis\Connection\StreamConnection->tcpStreamInitializer(Object(Predis\Connection\Parameters))
#3 /home/websiteroot/website/vendor/predis/predis/src/Connection/AbstractConnection.php(81): Predis\Connection\StreamConnection->createResource()
#4 /home/websiteroot/website/vendor/predis/predis/src/Connection/StreamConnection.php(258): Predis\Connection\AbstractConnection->connect()
#5 /home/websiteroot/website/vendor/predis/predis/src/Connection/AbstractConnection.php(180): Predis\Connection\StreamConnection->connect()
#6 /home/websiteroot/website/vendor/predis/predis/src/Connection/StreamConnection.php(288): Predis\Connection\AbstractConnection->getResource()
#7 /home/websiteroot/website/vendor/predis/predis/src/Connection/StreamConnection.php(394): Predis\Connection\StreamConnection->write('*2\
\
\
\
INCR\
\
$...')
#8 /home/websiteroot/website/vendor/predis/predis/src/Connection/AbstractConnection.php(110): Predis\Connection\StreamConnection->writeRequest(Object(Predis\Command\StringIncrement))
#9 /home/websiteroot/website/vendor/predis/predis/src/Client.php(331): Predis\Connection\AbstractConnection->executeCommand(Object(Predis\Command\StringIncrement))
#10 /home/websiteroot/website/vendor/predis/predis/src/Client.php(314): Predis\Client->executeCommand(Object(Predis\Command\StringIncrement))
#11 /home/websiteroot/website/vendor/laravel/framework/src/Illuminate/Redis/Connections/Connection.php(116): Predis\Client->__call('incr', Array)
#12 /home/websiteroot/website/vendor/laravel/framework/src/Illuminate/Redis/Connections/Connection.php(220): Illuminate\Redis\Connections\Connection->command('incr', Array)
#13 /home/websiteroot/website/vendor/laravel/horizon/src/Repositories/RedisJobRepository.php(97): Illuminate\Redis\Connections\Connection->__call('incr', Array)
#14 /home/websiteroot/website/vendor/laravel/horizon/src/JobId.php(27): Laravel\Horizon\Repositories\RedisJobRepository->nextJobId()
#15 /home/websiteroot/website/vendor/laravel/horizon/src/RedisQueue.php(167): Laravel\Horizon\JobId::generate()
#16 /home/websiteroot/website/vendor/laravel/framework/src/Illuminate/Queue/RedisQueue.php(154): Laravel\Horizon\RedisQueue->getRandomId()
#17 /home/websiteroot/website/vendor/laravel/framework/src/Illuminate/Queue/Queue.php(94): Illuminate\Queue\RedisQueue->createPayloadArray(Object(App\Jobs\OrderChecked), 'queues:default', '')
#18 /home/websiteroot/website/vendor/laravel/framework/src/Illuminate/Queue/RedisQueue.php(91): Illuminate\Queue\Queue->createPayload(Object(App\Jobs\OrderChecked), 'queues:default', '')
#19 /home/websiteroot/website/vendor/laravel/horizon/src/RedisQueue.php(46): Illuminate\Queue\RedisQueue->push(Object(App\Jobs\OrderChecked), '', NULL)
#20 /home/websiteroot/website/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(182): Laravel\Horizon\RedisQueue->push(Object(App\Jobs\OrderChecked))
#21 /home/websiteroot/website/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(158): Illuminate\Bus\Dispatcher->pushCommandToQueue(Object(Laravel\Horizon\RedisQueue), Object(App\Jobs\OrderChecked))
#22 /home/websiteroot/website/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(73): Illuminate\Bus\Dispatcher->dispatchToQueue(Object(App\Jobs\OrderChecked))
#23 /home/websiteroot/website/vendor/laravel/framework/src/Illuminate/Console/Scheduling/Schedule.php(160): Illuminate\Bus\Dispatcher->dispatch(Object(App\Jobs\OrderChecked))
#24 /home/websiteroot/website/vendor/laravel/framework/src/Illuminate/Console/Scheduling/Schedule.php(132): Illuminate\Console\Scheduling\Schedule->dispatchToQueue(Object(App\Jobs\OrderChecked), NULL, NULL)
#25 [internal function]: Illuminate\Console\Scheduling\Schedule->Illuminate\Console\Scheduling\{closure}()
#26 [internal function]: Closure->__invoke()
#27 /home/websiteroot/website/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): call_user_func_array(Array, Array)
#28 /home/websiteroot/website/vendor/laravel/framework/src/Illuminate/Container/Util.php(37): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#29 /home/websiteroot/website/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(95): Illuminate\Container\Util::unwrapIfClosure(Object(Closure))
#30 /home/websiteroot/website/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(39): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#31 /home/websiteroot/website/vendor/laravel/framework/src/Illuminate/Container/Container.php(596): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#32 /home/websiteroot/website/vendor/laravel/framework/src/Illuminate/Console/Scheduling/CallbackEvent.php(77): Illuminate\Container\Container->call(Array, Array)
#33 /home/websiteroot/website/vendor/laravel/framework/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php(143): Illuminate\Console\Scheduling\CallbackEvent->run(Object(Illuminate\Foundation\Application))
#34 /home/websiteroot/website/vendor/laravel/framework/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php(102): Illuminate\Console\Scheduling\ScheduleRunCommand->runEvent(Object(Illuminate\Console\Scheduling\CallbackEvent))
#35 [internal function]: Illuminate\Console\Scheduling\ScheduleRunCommand->handle(Object(Illuminate\Console\Scheduling\Schedule), Object(Illuminate\Events\Dispatcher), Object(App\Exceptions\Handler))
#36 /home/websiteroot/website/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): call_user_func_array(Array, Array)
#37 /home/websiteroot/website/vendor/laravel/framework/src/Illuminate/Container/Util.php(37): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#38 /home/websiteroot/website/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(95): Illuminate\Container\Util::unwrapIfClosure(Object(Closure))
#39 /home/websiteroot/website/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(39): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#40 /home/websiteroot/website/vendor/laravel/framework/src/Illuminate/Container/Container.php(596): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#41 /home/websiteroot/website/vendor/laravel/framework/src/Illuminate/Console/Command.php(134): Illuminate\Container\Container->call(Array)
#42 /home/websiteroot/website/vendor/symfony/console/Command/Command.php(258): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#43 /home/websiteroot/website/vendor/laravel/framework/src/Illuminate/Console/Command.php(121): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#44 /home/websiteroot/website/vendor/symfony/console/Application.php(911): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#45 /home/websiteroot/website/vendor/symfony/console/Application.php(264): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Console\Scheduling\ScheduleRunCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#46 /home/websiteroot/website/vendor/symfony/console/Application.php(140): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#47 /home/websiteroot/website/vendor/laravel/framework/src/Illuminate/Console/Application.php(93): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#48 /home/websiteroot/website/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(129): Illuminate\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#49 /home/websiteroot/website/artisan(36): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#50 {main}
"} 

I really appreciate your help. thank you very much

Activity icon

Replied to Keep Getting File Get Content Error (updated)

Apparently. it doesn't do any harm as far as I noticed. but the fact that when I open the log files there is a huge list of this error + the existence of an error I can't resolve is very annoying :)

Feb
27
3 months ago
Activity icon

Replied to Receive Wrong Html Response Rather Than Xml/json In Curl Request

so it's based on the max number that the API's provider has set? they informed us that they have not set any limits on the number of requests we can send.

Activity icon

Started a new Conversation Receive Wrong Html Response Rather Than Xml/json In Curl Request

I am sending curl request to an api. for first 20 requests I get the correct xml/json response. but after that I receive HTML response. I logged the urls that caused that, the urls work fine on the browser. when I send the request again with curl it receives the correct response. in my local machine I do not receive such error at all, no matter what I do. so it's really hard to recreate the issue to be able to debug it. I contacted the provider of the api. they logged our requests and ther responses. they send the correct response. we just don't get them apparently.

this is the content of the static function that I call:

$curl = curl_init();
curl_setopt_array($curl, array(
    CURLOPT_URL => $url,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 60,
    CURLOPT_FOLLOWLOCATION => false,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
    self::$message = 'CURL ERROR : '. $err;
    return false;
} else {
    try {
        $xml_res = simplexml_load_string($response, "SimpleXMLElement", LIBXML_NOCDATA);
        self::$response = $xml_res->asXML();
        return true;
    } catch (\Throwable $th) {
        self::$message = $th->getMessage();
        Log::error($th->getMessage());
        Log::error($url);
        Log::error($response);
        return false;
    }
    
}

I get this error in my log


simplexml_load_string(): Entity: line 28: parser error : Opening and ending tag mismatch: meta line 26 and head  
production.ERROR: url that we send to
production.ERROR: <!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <style type="text/css">
        html, body, #partner, iframe {
            height: 100%;
            width: 100%;
            margin: 0;
            padding: 0;
            border: 0;
            outline: 0;
            font-size: 100%;
            vertical-align: baseline;
            background: transparent;
        }

        body {
            overflow: hidden;
        }
    </style>
    <meta content="NOW" name="expires">
    <meta content="index, follow, all" name="GOOGLEBOT">
    <meta content="index, follow, all" name="robots">
    <!-- Following Meta-Tag fixes scaling-issues on mobile devices -->
    <meta content="width=device-width; initial-scale=1.0; maximum-scale=1.0;
            user-scalable=0;" name="viewport">
</head>
<body>

<div id="partner"></div>
<script type="text/javascript">
    function getParam() {
        var query = window.location.search.substring(1);
        var vars = query.split("&");
        for (var i = 0; i < vars.length; i++) {
            var pair = vars[i].split("=");
            if (pair[0] == 'domain') {
                return pair[1];
            }
        }
        return  window.location.host;
    }
    ;

    document.write(
            '<script type="text/javascript" language="JavaScript"'
                    + 'src="//sedoparking.com/frmpark/'
                    + getParam() + '/'
                    + 'sedopark'
                    + '/park.js">'
                    + '<\/script>'
    );
</script>
</body>
</html>    

I am using laravel 7. the script mentiones sedoparking! we don't have anything to do with sedoparking.

Feb
26
3 months ago
Activity icon

Replied to Keep Getting File Get Content Error (updated)

Really? installing modsecurity solved the issue completely? wow. hopefully that works for me too

Activity icon

Replied to Keep Getting File Get Content Error (updated)

yes you are right and that did not solve my issue