403 Error on Specific Ajax Post Requests with the specific request on WooCommerce Lumise Designer Page

Server keep giving me 403 Lite Speed Webserver error page, at below page of Lumise WordPress Plugin, when user checkout in ajax request on longer request only.
https://therenaissancemarket.com/personlize-designer/?product_base=6&product_cms=30262

I tried to analyze and found it comes on more than around 664082 bytes in content length or for longer post variables

I check phpinfo() and found
max_input_vars 1000
post_max_size 128M
upload_max_filesize 128
opcache.max_file_size 0
realpath_cache_size 4096

but its keep giving lite speed 403 web page.

then i disable mod_security just to be make sure that it is not cause of this.
But still issue is there 🙁

Can you guys please help me on the following?

1- Is there a way, we can see what causing 403 error for debug, i.e: post size or input vars or what? instead of 403 page so i can sort it?

2- Or if there is any specific configuration i need to set on Lite Speed?

By the way, server having details OpenLiteSpeed, Direct Admin Panel on Linux.

Below are the Logs I see on Mod_Security in Direct Admin Panel which shows the same ajax request, as shown in the image, Recent 10 Logs screenshot

Following is 1 of the Log details.

https://notepadely.com/X8GQQO

Laravel 11: Is it possible to force PHPUnit to trigger / “press” CTRL+C to simulate interruption of an artisan command?

I have an artisan command that can run for minutes or hours, processing multitude of records in a loop within the handle() method.

I have introduced the ability to interrupt such a long process by humans, by allowing them to press CTRL+C during command runtime.

The following code works flawlessly:

pcntl_async_signals(true);
pcntl_signal(SIGINT, [$this, 'shutdown']);
pcntl_signal(SIGTERM, [$this, 'shutdown']);

and as soon as user presses CTRL+C, the shutdown() method is being called. It doesn’t matter what shutdown() does, it matters that I can trigger it.

However when testing, I don’t know how can I simulate pressing CTRL+C to trigger shutdown, so that code-coverage shows body of shutdown as green (called), rather than red (not reached).

I’m already testing whether necessary methods are available:

public function test_sync_process_can_be_interrupted_by_user_via_terminal(): void
{
    $this->assertTrue(function_exists('pcntl_async_signals'));
    $this->assertTrue(function_exists('pcntl_signal'));
}

This test is green, but this is not enough for me. I want unit test to “press” these keys. How can I force PHPUnit to do so when testing my artisan command $this->artisan('my:long-command')?

I am trying to show my android app reviews on my website but return 401 when Authenticated

I am trying to show my android app reviews with reviewer name, date, rating. But I have some problems with authentication. Using google cloud with OAuth 2.0 Client IDs.

I use google/apiclient with PHP composer

{
"name": "app/reviews",
"description": "A project to fetch Google Play Store reviews using PHP",
"require": {
    "google/apiclient": "^2.15.0"
},
"autoload": {
    "psr-4": {
        "App\": "src/"
    }
  }
}

here’s

credentials.json

{
   "web":{
      "client_id":"******-********.apps.googleusercontent.com",
      "project_id":"****-****-373117",
      "auth_uri":"https://accounts.google.com/o/oauth2/auth",
      "token_uri":"https://oauth2.googleapis.com/token",
      "auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs",
      "client_secret":"GOCSPX-*******"
   }
}

here’s PHP code to show reviews

<?php
require '/path/to/vendor/autoload.php';

use GoogleClient;
use GoogleServiceAndroidPublisher;

function getReviews($applicationName) {
    $client = new Client();
    $client->setApplicationName('Reviews Client');
    $client->setAuthConfig('/path/to/credentials.json');
    $client->addScope(AndroidPublisher::ANDROIDPUBLISHER);
    
    $service = new AndroidPublisher($client);
    
    try {
        $reviews = $service->reviews->listReviews($applicationName);
        return $reviews;
    } catch (Exception $e) {
        echo 'Error: ', $e->getMessage();
        return null;
    }
}

$applicationName = 'com.****.****';
$reviews = getReviews($applicationName);

if ($reviews) {
    foreach ($reviews as $review) {
        echo 'Rating: ' . $review->getStars() . '<br>';
        echo 'Comment: ' . $review->getText() . '<br><br>';
    }
}
?>

but I get this when run it!

I want to know what’s the problem? Why Authentication failed.

Response

Connect PHP and SQL Server that i’m using visual studio code. using localhost and xampp as well

Where should I place my PHP file? It’s currently in a project folder.
I have downloaded the microsoft SQL Server extension in VSCode but still the undefine problem of couldn’t connect the database for running the website.
I’ve even follow the step from Utube but still there’s some errors that I may make careless but I can’t find it.


<?php

    $serverName = "localhost";
    $database = "WeighingDB";
    $uid = "sa";
    $pass = "1234567890";

    $connectionOptions = [
        "Database" => $database,
        "UID" => $uid,
        "PWD" => $pass
    ];

    $conn = sqlsrv_connect($serverName,$connectionOptions);
    if($conn == false) 
        //die(print_r(sqlsrv_errors(), true));
        echo 'failed';
    else
        echo 'Connected Successfully';
        

?>

A clear steps guiding me of connecting the PHP to the SQL Server and my other web program(htm, css, js). Connect to database

Invalid value for param; wrong type or other syntax error: timeIntervals LinkedIn API

I want to get my metric share statistics from my page LinkedIn, the docs in here: https://learn.microsoft.com/en-us/linkedin/marketing/community-management/organizations/share-statistics?view=li-lms-2024-06&tabs=curl

I tried in postman is working well, but when i implement to my code (i’m using PHP) is getting error:

{ “errorDetailType”: “com.linkedin.common.error.BadRequest”, “message”: “Invalid param. Please see errorDetails for more information.”, “errorDetails”: { “inputErrors”: [ { “description”: “Invalid value for param; wrong type or other syntax error”, “input”: { “inputPath”: { “fieldPath”: “timeIntervals” } }, “code”: “PARAM_INVALID” } ] }, “status”: 400 }

Here is my code:

$date_start = strtotime(date('Y-01-01 00:01:01'));
$date_end = strtotime(date('Y-m-d H:i:s'));
$response = Http::withHeaders([
            'Authorization' => 'Bearer ' . $accessToken,
            'Linkedin-Version' => '202406',
            'X-Restli-Protocol-Version' => '2.0.0',
        ])->get('https://api.linkedin.com/rest/organizationalEntityShareStatistics', [
            'q' => 'organizationalEntity',
            'organizationalEntity' => 'urn:li:organization:XXXXXXXX',
            'timeIntervals' => '(timeGranularityType:DAY,timeRange:(start:'.$date_start.',end:'.$date_end.'))',
        ]);
        return $response->json();

When i do $date_start & $date_end in hardcode like:

$date_start = 1704067200000;
$date_end = 1717113600000;

the result is still same error

But, when im not using timeIntervals params, is working well

What’s wrong with my code?

Thank you so much for you who answered and help me.

How to use accessToken to send mail by Microsoft 365 account in PHP?

I’m trying to use accessToken to send mail in Microsoft 365.

But when decode accessToken, I realize that it does not have any scopes inside.

So I guess that the reason why I can’t use this accessToken to send Mail.

This is my code to get accessToken before use it to send mail.

<?php
require 'vendor/autoload.php';

use GuzzleHttpClient;
use MicrosoftGraphGraph;

$guzzle = new Client();
$url = 'https://login.microsoftonline.com/' . $tenantId . '/oauth2/v2.0/token';
$token = json_decode($guzzle->post($url, [
    'form_params' => [
        'client_id' => $clientId,
        'client_secret' => $clientSecret,
        'scope' => 'https://graph.microsoft.com/.default',
        'grant_type' => 'client_credentials',
    ],
])->getBody()->getContents());

$accessToken = $token->access_token;

function base64UrlDecode($input) {
    $remainder = strlen($input) % 4;
    if ($remainder) {
        $addlen = 4 - $remainder;
        $input .= str_repeat('=', $addlen);
    }
    return base64_decode(strtr($input, '-_', '+/'));
}

function decodeJwt($jwt) {
    $parts = explode('.', $jwt);
    if (count($parts) === 3) {
        list($header, $payload, $signature) = $parts;
        $decodedPayload = base64UrlDecode($payload);
        return json_decode($decodedPayload, true);
    }
    return null;
}

$decodedToken = decodeJwt($accessToken);

if ($decodedToken) {
    echo "Decoded Token:n";
    print_r($decodedToken);
} else {
    echo "Failed to decode token.";
}
Decoded Token:
Array
(
    [aud] => https://graph.microsoft.com
    [iss] => https://sts.windows.net/tenant_id/
    [iat] => 1721285822
    [nbf] => 1721285822
    [exp] => 1721289722
    [aio] => E2dgYDh/MUzO53mMQvZEb9Xk23da1==
    [app_displayname] => WordPress send mail by PHP library
    [appid] => client_id
    [appidacr] => 1
    [idp] => https://sts.windows.net/150115f9-9fg2-468e-8256-31864c946d38/
    [idtyp] => app
    [oid] => information
    [rh] => information.
    [sub] => information
    [tenant_region_scope] => AS
    [tid] => tenant_id
    [ver] => 1.0
    [wids] => Array
            [0] => 0997a1d0-0d1d-4acb-b408-d5ca73121e90
        )
    [xms_idrel] => 7 4
    [xms_tcdt] => 1691395903
)

Could anyone help me to know what is the issue or what are the missing roles?

CURL download request from Google Picker API

I have this curl request that is working but when I go to view the image after I download it, it wont open because it says “we don’t support this file format”?

Here’s the request, the data is coming from the Google Picker API. A user selects the file and on selection I ajax the data to this curl request to save it to our server:

   //data coming from google picker api
    public function pickerdwload() {
        $data = $this->input->post();

        $oAuthToken = $data['accesstoken'];
        $fileId = $data['file_id'];

        $getUrl = 'https://www.googleapis.com/drive/v3/files/' . $fileId;
        $authHeader = 'Authorization: Bearer ' . $oAuthToken ;


        $ch = curl_init($getUrl);

        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);

        curl_setopt($ch, CURLOPT_HTTPHEADER, [$authHeader]);

        $data = curl_exec($ch);
        $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        $error = curl_errno($ch);

        curl_close($ch);

        file_put_contents("testdwld.jpg", $data);
    }

Everything is working, and I’m picking regular jpg files so the file extension in file_put_contents should work but won’t let me open the downloaded image?

Also I’ve verified the data oauth token and file ID are good and correct.

I’ve tried different paths, adding things to the $getUrl string like ?alt=media. It’s a fairly simple curl request and it’s doing the job and adding it to my server. But I can’t open the file?

Spa application (with iframes) to a modern SPA [closed]

I have a laravel project with php8.1, which as frontend uses simple, blade with Html, bootstrap, javascript other things on the front. This page consists of several modules or pages, which perform different things (business logic) and uses iframes to simulate a SPA, placing the main content of the page inside the iframe and removing the iframe each time a new module is loaded, this to remove all the dom and compiled scripts (which persist in the browser unless the page is reloaded), freeing memory space in the browser. This solution, although functional, seems rustic to me.

I would like to use a more modern tool to produce the SPA effect, along with the performance it offers without having to intervene much in the code. I have seen frameworks like react or vue, but from what little I have seen about their documentation I have assumed that I would have to make a lot of changes in the front end of the application. I would also like to know if it has been right or not to use SPA as a solution, since it works perfectly, although it can cut a little the screen space that can occupy some windows. Thanks for your attention.

DataTable Search

Please help me for searching.

If the search result pertains to employee information, what can I do to display the branch information they belong to on the first row of the table and the employee information on the next row?
For exam./ pic. Search result 7700 , but in this case only employee information is shown.enter image description here

<?php
require_once '../includes/db_connection.php';

if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['tab_id'])) {
    $tabId = intval($_POST['tab_id']);
    $searchText = isset($_POST['search_text']) ? $_POST['search_text'] : '';

    // Filial məlumatlarını və işçiləri veritabanından gətirin
    $sql = "SELECT b.id AS branch_id, b.branch_name, b.address AS branch_address, b.email AS branch_email, 
                   e.employee_name, e.position, c.company_name, e.internal_phone, e.mobile_phone, e.email 
            FROM branches b
            LEFT JOIN branch_employees e ON b.id = e.branch_id
            LEFT JOIN companies c ON e.company_id = c.id
            WHERE e.tab_id = $tabId 
              AND (b.branch_name LIKE '%$searchText%' OR b.address LIKE '%$searchText%' OR b.email LIKE '%$searchText%'
                   OR e.employee_name LIKE '%$searchText%' OR e.position LIKE '%$searchText%' OR c.company_name LIKE '%$searchText%')
            ORDER BY b.id, e.employee_name";
    $result = $conn->query($sql);

    if ($result->num_rows > 0) {
        $branchData = [];

        // Məlumatları qruplaşdırın
        while ($row = $result->fetch_assoc()) {
            $branchId = $row['branch_id'];
            if (!isset($branchData[$branchId])) {
                $branchData[$branchId] = [
                    'branch_name' => $row['branch_name'],
                    'branch_address' => $row['branch_address'],
                    'branch_email' => $row['branch_email'],
                    'employees' => []
                ];
            }

            if ($row['employee_name']) {
                $branchData[$branchId]['employees'][] = [
                    'employee_name' => $row['employee_name'],
                    'position' => $row['position'],
                    'company_name' => $row['company_name'],
                    'internal_phone' => $row['internal_phone'],
                    'mobile_phone' => $row['mobile_phone'],
                    'email' => $row['email']
                ];
            }
        }

        // Cədvəl quruluşunu göstərin
        echo '<style>';
        echo 'a.email-link { color: black; text-decoration: none; }';  // Email linkləri üçün stil
        echo '</style>';
        
        echo '<div class="table-responsive">';
        echo '<table id="employeeTable_' . $tabId . '" class="table table-hover table-bordered table-sortable table-float">';
        echo '<thead>';
        echo '<tr>';
        echo '<th>Ad</th>';
        echo '<th>Ünvan / Şirkət</th>';
        echo '<th>Vəzifə</th>';
        echo '<th>Daxili Telefon</th>';
        echo '<th>Mobil Telefon</th>';
        echo '<th>Email</th>';
        echo '</tr>';
        echo '</thead>';
        echo '<tbody>';

        // İşçi məlumatlarını göstərin və onların filial məlumatlarını əlavə edin
        $previousBranchId = null;

        foreach ($branchData as $branchId => $branch) {
            // İşçi məlumatlarını göstər
            if (!empty($branch['employees'])) {
                foreach ($branch['employees'] as $employee) {
                    // Filial məlumatlarını birinci dəfə göstərmək üçün
                    if ($previousBranchId !== $branchId) {
                        echo '<tr class="searchable" data-id="' . $branchId . '" data-index="' . $branch['branch_name'] . ' ' . $branch['branch_address'] . ' ' . mb_strtolower($branch['branch_name'] . ' ' . $branch['branch_address'] . ' ' . $branch['branch_email']) . '">';
                        echo '<td class="name"><strong>' . htmlspecialchars($branch['branch_name']) . '</strong></td>';
                        echo '<td class="position"><strong>' . htmlspecialchars($branch['branch_address']) . '</strong></td>';
                        echo '<td></td>';
                        echo '<td></td>';
                        echo '<td></td>';
                        echo '<td class="email"><strong><a class="email-link" href="mailto:' . htmlspecialchars($branch['branch_email']) . '">' . htmlspecialchars($branch['branch_email']) . '</a></strong></td>';
                        echo '</tr>';
                        $previousBranchId = $branchId;
                    }

                    echo '<tr class="searchable" data-id="' . $employee['employee_name'] . '" data-index="' . $employee['employee_name'] . ' ' . $employee['position'] . ' ' . $employee['company_name'] . ' ' . $employee['internal_phone'] . ' ' . $employee['mobile_phone'] . ' ' . mb_strtolower($employee['employee_name'] . ' ' . $employee['position'] . ' ' . $employee['company_name'] . ' ' . $employee['internal_phone'] . ' ' . $employee['mobile_phone'] . ' ' . $employee['email']) . '">';
                    echo '<td class="name">' . htmlspecialchars($employee['employee_name']) . '</td>';
                    echo '<td class="position">' . htmlspecialchars($employee['company_name']) . '</td>';
                    echo '<td class="position">' . htmlspecialchars($employee['position']) . '</td>';
                    echo '<td class="mobile">' . htmlspecialchars($employee['internal_phone']) . '</td>';
                    echo '<td class="mobile">' . htmlspecialchars($employee['mobile_phone']) . '</td>';
                    echo '<td class="email"><a class="email-link" href="mailto:' . htmlspecialchars($employee['email']) . '">' . htmlspecialchars($employee['email']) . '</a></td>';
                    echo '</tr>';
                }
            } else {
                // Heç bir işçi tapılmadı mesajını göstər
                echo '<tr>';
                echo '<td colspan="6" class="text-muted">Heç bir işçi tapılmadı.</td>';
                echo '</tr>';
            }
        }

        echo '</tbody>';
        echo '</table>';
        echo '</div>';
    } else {
        echo '<p class="text-muted">Heç bir məlumat tapılmadı.</p>';
    }

    $conn->close();
} else {
    echo '<p class="text-muted">Xəta: POST məlumatları alınmadı.</p>';
}
?>

If the search result pertains to employee information, what can I do to display the branch information they belong to on the first row of the table and the employee information on the next row?
For exam./ pic. Search result 7700 , but in this case only employee information is shown.enter image description here

Php compose PSR-4 class auto loading not working on live server

I am using composer autoloading in PHP.
This code is working fine in my xammp sever as you can see I am passing class as an argument in my router array no error occurred and the class automatically get loaded in Router.php but on live server the class doesn’t get loaded and give errors
The application class is easily loaded in live server too so it means I put the write path in composer.json but it gives error when I pass the class as an argument to router and the router would have to load that class.


<?php
declare(strict_types=1);
$dir = dirname(__DIR__);
require_once $dir."/vendor/autoload.php";
use MuthishimApiFrameworkRequestHandlersAddproduct;
use MuthishimApiFrameworkControllersSiteController;
use DotenvDotenv;

use MuthishimApiFrameworkClassesApplication;

$dotenv = Dotenv::createImmutable($dir);
$dotenv->load();

$app = new Application($dir);

$app->router->get('/', [SiteController::class, 'home']);

This SiteController class is loaded in my xammmp server exactly as it is supposed to be but in live server it doesn’t get loaded and give me class not found error.

Prestashop 1.6: Inventory Management cart Availability message incorrect

I am using prestashop 1.6 with inventory management activated. I also allowed to order when product is out of stock.
I have a product that has variations (colors). I have 2 blue in stock and 0 red in stock. The blue product has the message “Avaible in 48h” the red has “In one week”. My problem is when I order 3 blue, in my cart I have the “48” not the “1 week ” message.

Did I misunderstood how Prestashop work ? did someone had something similar.

I checked the “shopping-product-line.tpl”. Checked the message in my parameters.

How to make an authentication in azure with socialite in a laravel application

Good morning,

I want to do an Azure authentication with socialite and laravel (+ react client side)

I have already set up the base and it is functional (authentication with socialite, send code on the front end to then be able to obtain user token/data)

but during deployment I get this error “Proof Key for Code Exchange is required for cross-origin authorization code redemption.”

I don’t think I did this authentication correctly.

Do you have any recent documentation to recommend to me for different Azure server/client authentication?

Thank you

This is what i have done for now :

Server side – laravel php

Routes api.php

Route::get('/auth/check-token', [AuthController::class, 'checkToken']);
Route::get('/auth/azure/redirect', [AuthController::class, 'authRedirectWithAzure']);
Route::post('/auth/exchange', [AuthController::class, 'exchangeCodeForToken']);

AuthController.php

   public function checkToken(Request $request)
    {
        $token = $request->cookie('auth_token');
        $isValid = $this->authService->checkToken($token);
        return response()->json(['isAuthenticated' => $isValid]);
    }

    public function authRedirectWithAzure(Request $request)
    {
        try {
            $scopes = ['openid', 'profile', 'email', 'offline_access'];

            $url = Socialite::driver('azure')->scopes($scopes)->stateless()->redirect()->getTargetUrl();

            if ($url) {
                return response()->json($url);
            }
        } catch (Throwable $th) {
            return $this->logService->sendLog(
                $th->getMessage(),
                'Failed to connect to Microsoft Azure.',
                'connection with azure',
                $request->ip(),
                $request->url(),
                'Failed to connect to Microsoft Azure.',
                HttpStatus::INTERNAL_SERVER_ERROR
            );
        }
    }

    public function exchangeCodeForToken(Request $request)
    {
        try {
            $user = Socialite::driver('azure')->stateless()->user();

            if ($user) {
                $token = $user->token;

                $refreshToken = $user->refreshToken;
                $expiresIn = $user->expiresIn;

                $response = Http::withHeaders([
                    'Authorization' => 'Bearer ' . $token
                ])->get('https://graph.microsoft.com/v1.0/me');

                if ($response->successful()) {

                    session([
                        'microsoft_token' => $token,
                        'microsoft_refresh_token' => $refreshToken,
                        'microsoft_token_expires' => now()->addSeconds($expiresIn)->timestamp,
                    ]);

                    $cookie = cookie('auth_token', $token, 120, '/', null, false, true, false, 'Strict');


                    return response()->json([
                        'userData' => $response->json(),
                        'message' => 'Authentication successful',
                    ], 200)->withCookie($cookie);
                }
            } else {
                return $this->logService->sendLog(
                    'error',
                    'Error to process user data and set cookie response',
                    'processexchangeCodeForTokenRequest',
                    $request->ip(),
                    $request->url(),
                    "Request to exchangeCodeForToken don't success.",
                    HttpStatus::INTERNAL_SERVER_ERROR
                );
            }
        } catch (Throwable $th) {

            return $this->logService->sendLog(
                $th->getMessage(),
                'Unexpected error during Azure authentication.',
                'azure authentication',
                $request->ip(),
                $request->url(),
                'Unexpected error',
                HttpStatus::INTERNAL_SERVER_ERROR
            );
        }
    }

Client side :

Index.js

const msalInstance = new PublicClientApplication(msalConfig);

store.dispatch(getCategories());

const root = ReactDOM.createRoot(document.getElementById('root'));

root.render(
  <Provider store={store}>
    {' '}
    <MsalProvider instance={msalInstance}>
      <ThemeProvider theme={muiTheme}>
        <AuthProvider>
          <App />
        </AuthProvider>
      </ThemeProvider>
    </MsalProvider>{' '}
  </Provider>
);

authContext.js

import React, { createContext, useContext, useState, useEffect } from 'react';
import api from 'config/api';
import { useDispatch } from 'react-redux';
import { setUserData } from 'feature/user';

const AuthContext = createContext(null);

export const AuthProvider = ({ children }) => {
  const dispatch = useDispatch();
  const [isAuthenticated, setIsAuthenticated] = useState(false);

  const checkAuth = async () => {
    try {
      const response = await api.get('api/auth/check-token');
      if (response.status === 200) {
        setIsAuthenticated(response.data.isAuthenticated);
      } else {
        setIsAuthenticated(false);
      }
    } catch (error) {
      console.error(
        "Erreur lors de la vérification de l'authentification",
        error
      );
      setIsAuthenticated(false);
    }
  };


  useEffect(() => {
    checkAuth();
  }, []);

  const login = async (code) => {
    try {
      const response = await api.post('api/auth/exchange', { code });
      if (response.status === 200) {
         await checkAuth();

        dispatch(setUserData(response.data.userData));
      } else {
        console.error('Token exchange failed', response.status);
      }
    } catch (err) {
      console.error('Error during token exchange:', err);
    }
  };

  const logout = async () => {
    setIsAuthenticated(false);

    try { 
      const res = await api.delete('api/auth/logout');
      if (res) {
         window.location.href = res.data.logoutUrl;
      }
    } catch (error) {
      console.log(error, "erreur lors de l'appel de la déconnexion");
    }
  };

  return (
    <AuthContext.Provider value={{ isAuthenticated, login, logout }}>
      {children}
    </AuthContext.Provider>
  );
};

export const useAuth = () => useContext(AuthContext);

Login.js

export const Login = () => {
  const { login } = useAuth();
  const navigate = useNavigate();

  const handleTokenExchange = async () => {
    try {
      const urlParams = new URLSearchParams(window.location.search);
      const code = urlParams.get('code');
      if (code) {
        await login(code);
        navigate('/home');
      } else {
        const res = await api.get('api/auth/azure/redirect');
        window.location.href = res.data;
      }
    } catch (err) {
      console.log('Error initiating Azure login:', err);
    }

  };

  useEffect(() => {
    handleTokenExchange();
  }, []);}

Laravel 8 PHP return single decimal place only when the last decimal number is 0

I am currently updating some code in our backend system since the mobile app has already been deployed and we don’t have a mobile app developer at the moment.

        $fees = $this->fees;
        $stant_fee = 0;
        foreach($fees as $fee){
            if($fee->is_override){
                $stant_fee+=$fee->override_amount;
            }else{
                $stant_fee+= $fee->commission_fee;
            }
        }
        return round((double) $stant_fee + (double) $this->amount_per_kwh, 2);

The code works well, always returning 2 decimal places. However, if the float ends with a 0, PHP cancels the last 0, returning only 1 decimal place. For example, if the total is 0.60, it returns 0.6. How can I ensure it always returns 2 decimal places?

I have already tried using ‘number_format’ and ‘sprintf’, but the data type returned is a string. When I cast it back to a float, it still cancels the 0, returning 0.6 again.

I also tried addbc, ceil and round but still it return 1 decimal only.

please give me instructions to solve the Question ? i run the project using php artisan server commant but it appears a connection problem

SQLSTATE[HY000] [1045] Access denied for user ‘root’@’localhost’ (using password: NO) (Connection: mysql, SQL: select * from sessions where id = sxxVXv6VTQl3sW2XaydEJPBITIpsmNKO898Pik2H limit 1)
i run the project and in the web server appears like this. please help to solve the question.

correct page when it runs