Error while writing to Excel via Graph API – Worked for a while, then stops

I have made a connection between an azure app and an online 365 excel document on my organisations sharepoint via Graph api. I was for a while able to create,update and delete rows in my table via the graph api and it all seemed to worked. But after a while i wasnt able to open my excel document in the browser and therefore is my document not updating anymore(the graph api is not working writing/updating). When i create a copy of the excel file and try to connect it again with my php code it works again for awhile and then stop working. I think it has something to do with the amount of session my code is making through graph api even though i only make one session and is closing that session again. Im using the same session id in my requests. Im not sure that its the problem, so that is why im asking here. I can still open the excel file in my desktopapp but its still not updating the rows.

My error when trying to open excel in browser is: “You do not have permission to open this file in Excel on the web, but you can open it in the desktop app.”

Before the Browser closes the document down for good, im experiencing this error for a while:
Error

My php code is this:


function create_session1 ($Token){
$getRowsUrl = "https://graph.microsoft.com/v1.0/users/{userid}/drive/items/{id}/workbook/createSession";

 // Execute the request to get existing rows
    $getRowsResponse = wp_remote_post($getRowsUrl, [
        'headers' => [
            'Authorization' => "Bearer $Token",
        ],
    ]);

    // Check for errors in the get rows request
    if (is_wp_error($getRowsResponse)) {
        // Handle the error here
        error_log("Error get: " . $getRowsResponse->get_error_message());
        return false;
    }

    // Decode the JSON response
    $getRowsResult = json_decode(wp_remote_retrieve_body($getRowsResponse), true);
     return $sessionid = $getRowsResult['id'];
    
}

function close_session1($token, $sessionId) {
    $closeSessionUrl = "https://graph.microsoft.com/v1.0/users/{userid}/drive/items/{id}/workbook/closeSession";

    // Execute the request to close the session
    $closeSessionResponse = wp_remote_request($closeSessionUrl, [
        'method' => 'POST',
        'headers' => [
            'Authorization' => "Bearer $token",
            'Workbook-Session-Id' => $sessionId,
        ],
    ]);

    // Check for errors in the close session request
    if (is_wp_error($closeSessionResponse)) {
        // Handle the error here
        error_log("Error closing session: " . $closeSessionResponse->get_error_message());
        return false;
    }

    // Return true if the session was closed successfully
    return true;
}

function get_clients_from_tb1($accessToken){
 $args = array(
        'headers' => array(
            'Authorization'=> 'Bearer $Token',
        ),
    );

    // Modify the API URL to include the identifier
    $apiUrl = 'https://system.easypractice.net/api/v1/clients?page_size=500';
    $response = wp_remote_get($apiUrl, $args);
    if (is_wp_error($response)) {
        $error_message = $response->get_error_message();
        echo "Something went wrong1: $error_message";
        return;
    }


    $status = wp_remote_retrieve_response_code($response);
    if ($status !== 200) {
        echo "Received HTTP status code: $status";
           return;
    }

     $data = json_decode(wp_remote_retrieve_body($response), true);
    $client_data = $data['data'][0]['phone'];
   
    $all_client_ids_from_tb = array();

    if (isset($data['data']) && is_array($data['data'])) {
    // Loop through each element in the 'data' array
    $sessionid = create_session1($accessToken);
    foreach ($data['data'] as $client_data) {
        // Do something with each element
        $all_client_ids_from_tb[] = $client_data['id'];
        post_data_to_excel1($accessToken,$client_data,$sessionid);      
    }
}
delete_rows_not_in_data1($accessToken,$all_client_ids_from_tb,$sessionid);
close_session1($accessToken,$sessionid);
}
get_clients_from_tb1($accessToken);

The code is executed by a cronjob on the server every hour.

I have tried to implement session via the graph API but it doesnt seem to have helped. It could be that is wrongly implemented. I have also tried the code on a fresh document.Furthermore i have tried to look for a solution to update an desktopapp version and forget about the browser version.

Not working multi-filter system in my real estate Laravel 10 project

I hope you all are doing well. I am developing a real estate website, there is a property page. In this page the requirement is that there will be a multi filtering system. User can filter properties by category, price range, parking spots, and BHK(Bedroom, Hall and Kitchen). Suppose user first will select apartment category, according to that category every property will show, after that suppose user will select 3 BHK, then 3 BHK apartment properties will show, after that suppose user will select a price range between 2000 and 3000 USD, then 3 BHK apartment properties which has a price range between 2000 and 3000 USD will show. Right now Category filter is working but other filters are not working accordingly.
Here is the property.blade.php :-


@extends('frontend.layouts.main')

@section('main-container')

<div class="page-heading header-text">
  <div class="container">
    <div class="row">
      <div class="col-lg-12">
        <span class="breadcrumb"><a href="#">Home</a> / Properties</span>
        <h3>Properties</h3>
      </div>
    </div>
  </div>
</div>

<div class="section properties">
  <div class="container">
    <ul class="properties-filter">
      <li><a class="is_active" href="#!" data-filter="*">Show All</a></li>
      <li><a href="#!" data-filter=".apartment">Apartment</a></li>
      <li><a href="#!" data-filter=".luxury-villa">Luxury Villa</a></li>
      <li><a href="#!" data-filter=".penthouse">Penthouse</a></li>
      <li><a href="#!" data-filter=".modern-condo">Modern Condo</a></li>
    </ul>
    <div class="filters">
      <!-- Price Filter -->
      <div class="filter-item">
        <label for="priceRange">Price Range:</label>
        <input type="range" id="priceRange" min="500" max="3000" value="500" class="slider">
        <span id="priceValue">$500</span>
    </div>


      <!-- Parking Lots Filter -->
      <div class="filter-item">
          <label>Parking Spots:</label>
          <div>
              @foreach([3, 6, 8, 10] as $spots)
              <input type="radio" id="parking{{ $spots }}" name="parkingSpots" value="{{ $spots }}">
              <label for="parking{{ $spots }}">{{ $spots }} spots</label>
              @endforeach
          </div>
      </div>

      <!-- BHK Filter -->
      <div class="filter-item">
          <label for="bhk">BHK:</label>
          <select id="bhk" class="form-select">
              <option value="*">All</option>
              @foreach([2, 3, 4] as $bhk)
              <option value="{{ $bhk }}">{{ $bhk }} BHK</option>
              @endforeach
          </select>
      </div>
  </div>

    <div class="row properties-box">
      @foreach ($properties as $property)
      <div class="col-lg-4 col-md-6 align-self-center mb-30 properties-items {{ strtolower(str_replace(' ', '-',   $property->category_name)) }}"
        data-price="{{ $property->price }}"
        data-bhk="{{ $property->bhk }}"
        data-parking="{{ $property->parking }}">

        <div class="item">
            <a href="{{ route('property-details', $property->id) }}"><img src="{{ asset('storage/' . $property->property_image) }}" alt=""></a>
            <span class="category">{{ $property->category_name }}</span>
            <h6>{{ $property->price }}</h6>
            <h4><a href="{{ route('property-details', $property->id) }}">{{$property->property_name}}</a></h4>
            <ul>
                <li>Address: <span><a href="{{ route('property-details', $property->id) }}">{{ $property->address }}</a></span></li>
                <li><span>{{ $property->bhk }} BHK</span></li>
                <li>Area: <span>{{ $property->area }}</span></li>
                @if (in_array($property->category_name, ["Apartment", "Penthouse", "Modern Condo"]))
                <li>Floor: <span>{{ $property->floor }}th</span></li>
                @else
                <li>Floor: <span>{{ $property->floor }}</span></li>
                @endif
                <li>Parking: <span>{{ $property->parking }}</span></li>
            </ul>
            <div class="main-button">
                <a href="{{ route('property-details', $property->id) }}">Schedule a visit</a>
            </div>
        </div>
    </div>
@endforeach
</div>
    </div>
    <div class="row">
      <div class="col-lg-12">
        <ul class="pagination">
          <li><a href="#">1</a></li>
          <li><a class="is_active" href="#">2</a></li>
          <li><a href="#">3</a></li>
          <li><a href="#">>></a></li>
        </ul>
      </div>
    </div>
  </div>
</div>

    @endsection

    @section('title')
    Property
    @endsection

property-fliter-script.js :-

document.addEventListener("DOMContentLoaded", function() {
    const filters = {
        category: document.querySelectorAll('.properties-filter a'),
        priceRange: document.getElementById('priceRange'),
        parkingSpots: document.querySelectorAll('input[name="parkingSpots"]'),
        bhk: document.getElementById('bhk')
    };

    const priceValueDisplay = document.getElementById('priceValue');

    // Function to initially show all properties when the page loads
    function showAllProperties() {
        document.querySelectorAll('.properties-items').forEach(item => {
            item.style.display = "block";
        });
    }

    // Initial function call to show all properties
    showAllProperties();

    // Update price display
    filters.priceRange.oninput = function() {
        priceValueDisplay.textContent = `$${this.value}`;
        applyFilters();
    }

    function applyFilters() {
        const selectedPrice = parseInt(filters.priceRange.value, 10);
        let selectedParking = null;
        filters.parkingSpots.forEach(radio => {
            if (radio.checked) selectedParking = parseInt(radio.value, 10);
        });
        const selectedBhk = parseInt(filters.bhk.value, 10);

        document.querySelectorAll('.properties-items').forEach(item => {
            const price = parseInt(item.dataset.price, 10);
            const parking = parseInt(item.dataset.parking, 10);
            const bhk = parseInt(item.dataset.bhk, 10);

            const priceMatch = !selectedPrice || (price <= selectedPrice);
            const parkingMatch = !selectedParking || (parking === selectedParking);
            const bhkMatch = !selectedBhk || (bhk === selectedBhk);

            item.style.display = (priceMatch && parkingMatch && bhkMatch) ? "block" : "none";
        });
    }

    // Event listeners for BHK and Parking changes
    filters.bhk.addEventListener('change', applyFilters);
    filters.parkingSpots.forEach(radio => radio.addEventListener('change', applyFilters));

    // Apply category filters independently from the other filters
    filters.category.forEach(filter => {
        filter.addEventListener('click', function(e) {
            e.preventDefault();
            const category = this.getAttribute('data-filter');
            document.querySelectorAll('.properties-items').forEach(item => {
                if (category === "*" || item.classList.contains(category.substring(1))) {
                    item.style.display = "block";
                } else {
                    item.style.display = "none";
                }
            });
            filters.category.forEach(f => f.classList.remove('is_active'));
            this.classList.add('is_active');
        });
    });
});



PropertyController.php :-

<?php

namespace AppHttpControllers;

use IlluminateHttpRequest;
use AppModelsPropertyDetail;

class PropertyController extends Controller
{
    public function index(){
        // Fetch all properties from the database
        $properties = PropertyDetail::all();

        // Pass the properties to the view
        return view('frontend.property', compact('properties'));
    }

    /**
     * Show the details for a specific property.
     *
     * @param  int  $id
     * @return IlluminateHttpResponse
     */
    public function showPropertyDetails($id)
    {
        // Fetch the property detail by ID
        $property = PropertyDetail::findOrFail($id);

        // Pass the property detail to the view
        return view('frontend.property-details', compact('property'));
    }


}



Please help me. Is there way to resolve this ? are there any libraries or any other way to fix this issue.

I checked if JavaScript file is perfectly implemented in the footer, and I checked the property blade file for any kind of error but I cannot figured out what is causing this issue. According to requirement User can filter properties by category, price range, parking spots, and BHK(Bedroom, Hall and Kitchen). Suppose user first will select apartment category, according to that category every property will show, after that suppose user will select 3 BHK, then 3 BHK apartment properties will show, after that suppose user will select a price range between 2000 and 3000 USD, then 3 BHK apartment properties which has a price range between 2000 and 3000 USD will show. Right now Category filter is working but other filters are not working accordingly.

I don’t want to show the placeholder as a first option in the ChoiceType dropdown, using symfony 5

I have created a contact form with symfony 5.3 and I have been asked to delete the placeholder showing as a first option when you click the dropdown:

enter image description here

This is my Form Type code for the dropdown:

->add('department', ChoiceType::class, [
            'placeholder' => 'contact_form.department.label',
            'choices' => [
                'Unsubscribe' => 'Unsubscribe',
                'Sales' => 'Sales',
                'Marketing' => 'Marketing',
                'Customer Support' => 'Customer Support',
            ],
            'required' => true,
            'constraints' => [
                new NotBlank([
                    'message' => 'contact_form.department.not_blank',
                ]),
            ],
        ])

And the part of the twig template:

 <div class="col-md-6">
            <div class="form-select-wrapper mb-4">
                {{ form_widget(form.department, {'attr': {'class': 'form-select', 'id': 'form-select', 'required': true, 'onchange': 'showValidationMessage(this, "department-valid-feedback", "department-error")'}}) }}
                <div id="department-error" style="color: red; font-size: 14px; margin-top: 5px;">
                    {{ form_errors(form.department)|trans|raw }}
                </div>
                <div class="valid-feedback" id="department-valid-feedback" style="display: none;">
                    {{ 'Looks good!'|trans|raw }}
                </div>
            </div>
        </div>

I can’t find the solution in the symfony docs.

Laravel Supervisor “could not open file: artisan” error

So I’m running supervisor in background in my production server to do two things:

  1. php artisan queue:work
  2. php artisan schedule:work

The problem is that queue work is working fine, but the schedule work throws “could not open file: artisan” error!

Here’s my supervisor conf:

[program:influencer-queue-worker]
process_name=%(program_name)s_%(process_num)02d
command=php8.1 /home/scodus/domains/influencer.scodus.com/public_html/artisan queue:work --sleep=3 --tries=1
autostart=true
autorestart=true
user=scodus
numprocs=1
redirect_stderr=true
stdout_logfile=/home/scodus/domains/influencer.scodus.com/queue.log

[program:influencer-schedule-worker]
process_name=%(program_name)s_%(process_num)02d
command=php8.1 /home/scodus/domains/influencer.scodus.com/public_html/artisan schedule:work
autostart=true
autorestart=true
user=scodus
numprocs=1
redirect_stderr=true
stdout_logfile=/home/scodus/domains/influencer.scodus.com/schedule.log

Here’s my Console/Kernel.php

protected function schedule(Schedule $schedule)
    {
        $schedule->command('inspire')->everyMinute()->sendOutputTo(storage_path('logs/inspire.log'));
        $schedule->command('order:revenue-pending-to-available')->everyMinute();
        $schedule->command('order:cancel-without-requirements')->everyMinute();
        $schedule->command('order:autocomplete-delivery-attempted-orders')->everyMinute();
    }

WooCommerce pre select product attribute

In WooCommerce, If I have a product with only one option available, I need to pre select it.

I tried:

add_filter('woocommerce_dropdown_variation_attribute_options_args', 'fun_select_default_option', 10, 1);

function fun_select_default_option($args) {
    if (count($args['options']) === 1) {
        $onlyOption = reset($args['options']);
        if (!isset($onlyOption['disabled']) || !$onlyOption['disabled']) {
            $args['selected'] = $onlyOption;
        }
    }
    return $args;
}

This works if a dropdwown has only one option and that option is available. But not if there’s 3 and one available.

So I tried filtering out available options but still does not work:

add_filter('woocommerce_dropdown_variation_attribute_options_args', 'fun_select_default_option', 10, 1);

function fun_select_default_option($args) {
    $selectableOptions = array_filter($args['options'], function($option) {
        return !isset($option['disabled']) || !$option['disabled'];
    });

    if (count($selectableOptions) === 1) {
        $onlyOption = reset($selectableOptions);
        $args['selected'] = $onlyOption;
    }

    return $args;
}

It should pre-select if only one option for attribute is available.

how can I merge 3 users tables into 1 user table and my old php code will work? [closed]

I have 3 users tables in MARIADB and I need to merge it into 1 to have only id,name,email,password and for each user category new ralation table with aditional informations.

CREATE TABLE admin_wp.mlm_user (
  id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT ,
  code VARCHAR(20) NOT NULL ,
  status_wi TINYINT(4) UNSIGNED NOT NULL DEFAULT 0,
  id_wi BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
  leader TINYINT(4) UNSIGNED NOT NULL DEFAULT 0 ,
  mail VARCHAR(255) NOT NULL ,
  password VARCHAR(255) NOT NULL ,
  status TINYINT(4) UNSIGNED NOT NULL DEFAULT 1 ,
  login VARCHAR(255) DEFAULT '',
  role ENUM('director','administrator','user','company') DEFAULT 'user',
  utv VARCHAR(255) NOT NULL,
  utv_id BIGINT(20) UNSIGNED NOT NULL,
  crd1 TINYINT(4) UNSIGNED NOT NULL DEFAULT 0,
  crd2 TINYINT(4) UNSIGNED NOT NULL DEFAULT 0,
  crd3 TINYINT(4) UNSIGNED NOT NULL DEFAULT 0,
  password_original VARCHAR(255) NOT NULL DEFAULT '',
  kontakt INT(11) DEFAULT NULL,
  inVillage INT(4) DEFAULT NULL,
  card_info VARCHAR(255) DEFAULT NULL,
  show_phone TINYINT(4) DEFAULT 0,
  show_email TINYINT(4) DEFAULT 0,
  PRIMARY KEY (id)
);

CREATE TABLE admin_wp.village_companies (
  id BIGINT(20) NOT NULL AUTO_INCREMENT,
  name VARCHAR(100) NOT NULL,
  nip VARCHAR(255) NOT NULL,
  address VARCHAR(100) NOT NULL,
  id_v BIGINT(20) NOT NULL,
  user_name VARCHAR(100) NOT NULL,
  user_lastname VARCHAR(100) NOT NULL,
  phone INT(11) NOT NULL,
  email VARCHAR(100) NOT NULL,
  password VARCHAR(100) NOT NULL,
  catalog_province BIGINT(20) DEFAULT 0,
  catalog_region BIGINT(20) DEFAULT 0,
  catalog_gmina VARCHAR(255) DEFAULT '',
  catalog_village BIGINT(20) DEFAULT 0,
  workers VARCHAR(255) DEFAULT NULL,
  form VARCHAR(255) DEFAULT NULL,
  bio MEDIUMTEXT DEFAULT NULL,
  avatar VARCHAR(255) DEFAULT NULL,
  adr_id_wo BIGINT(20) DEFAULT NULL,
  adr_id_po BIGINT(20) DEFAULT NULL,
  worker VARCHAR(255) DEFAULT NULL,
  show_email TINYINT(4) DEFAULT 1,
  show_phone TINYINT(4) DEFAULT 1,
  show_user_name TINYINT(4) DEFAULT 1,
  w_text MEDIUMTEXT DEFAULT NULL,
  id_v_register BIGINT(20) DEFAULT NULL,
  type_d VARCHAR(255) DEFAULT NULL,
  w_slug VARCHAR(255) DEFAULT NULL,
  points INT(11) DEFAULT 0,
  user_type VARCHAR(255) DEFAULT NULL,
  location_id VARCHAR(255) DEFAULT NULL,
  code VARCHAR(255) DEFAULT NULL,
  PRIMARY KEY (id)
);

CREATE TABLE admin_wp.pp_users_list (
  id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
  status TINYINT(4) UNSIGNED NOT NULL DEFAULT 1,
  user_name VARCHAR(255) NOT NULL,
  phone VARCHAR(255) NOT NULL,
  address VARCHAR(255) NOT NULL,
  login VARCHAR(255) NOT NULL,
  password VARCHAR(255) NOT NULL,
  comment TEXT NOT NULL,
  role TINYINT(4) UNSIGNED NOT NULL DEFAULT 0,
  id_wi INT(10) UNSIGNED NOT NULL DEFAULT 0,
  confirmation TINYINT(4) UNSIGNED NOT NULL DEFAULT 0,
  forum_status INT(11) UNSIGNED ZEROFILL DEFAULT NULL,
  in_team TINYINT(4) DEFAULT NULL,
  team_role VARCHAR(100) DEFAULT NULL,
  show_email TINYINT(4) DEFAULT 0,
  show_phone TINYINT(4) DEFAULT 0,
  can_edit TINYINT(4) DEFAULT 0,
  show_team TINYINT(4) DEFAULT 0,
  add_landing TINYINT(4) DEFAULT 0,
  PRIMARY KEY (id)
);

I need to somehow merge this 3 tables into 1 and relations to work , php code to work without changing it (insert,update, select).Maybe something with table views but I dont know what to do with relations. Is this posible ? Please help.

how can change foreach array to getting a item in php 7.4 (I didn’t have problem in php 5.4) [duplicate]

I didn’t have problem with this function in php 5.4 but in upgrading script i have this probem. my function in the function.php file through which I call the language files of the project.

class sblib {
    var $sblang = "";
    var $lang = "";

    function load_lang($file_lang) {
        global $sbportals;
        $mlang = $this->sblang;
        if ($sbportals->member['sb_lang']) {    
            $dir = @opendir($this->sitepath."sbportal/lang/");
            while (($dirt = readdir($dir)) !== false) {
                $sbl = strtolower (substr($dirt, 0, 3));        
                $bol = strtolower (substr($sbportals->member['sb_lang'], 0, 3));
                if ($sbl == $bol && $dirt != ".htaccess" && $dirt != "htaccess" && $dirt != "index.html" && $dirt != "English_Reference") {
                    $mlang = $this->sitepath."sbportal/lang/".$dirt;
                }   
            }   
            closedir($dir);
        }

        require "$mlang/$file_lang";
        foreach ($langsb as $k => $v) {

            $this->lang[$k] = stripslashes($v);////this line///

            }
    }

    $sblib = new sblib;
    $sblib->stimer();
    $sblib->sblang = $sb_PATH."sbportal/lang/".$sb_LANG;

This is the content of the language file (lang_search.php):

$langsb['ad_langs_group'] = "Group";
$langsb['ad_langs_group_title'] = "Group Title";
$langsb['ad_langs_sel_title'] = "Language Administration";
$langsb['ad_langs_sel_info'] = "Choose the language";

Then by calling the function (once in each file of the project) as follows

$sblib->load_lang("lang_search.php");

And using the calling function wherever I need as below

{$sblib->lang['download']}

I can use translation files for translate of each words. I had no problem until php 5.6, but I see this error when upgrading to 7.4.

Warning: Illegal.string.offset.'download'.in ... (////this line///)

please help me to solve.

I have checked all the ways and pages of the stackoverflow.

Telescope – Laravel menu path issue

I have installed and configured Laravel Telescope with my Laravel 10 project

telescope.php

'path' => env('TELESCOPE_PATH', 'telescope')

AppServiceProvider.php

public function register(): void
{
    if ($this->app->environment('local')) {
        $this->app->register(LaravelTelescopeTelescopeServiceProvider::class);
        $this->app->register(TelescopeServiceProvider::class);
    }
}

When I enter “my-project-path/telescope” in the URL, the dashboard loads perfectly. However, the URLs for all menus (such as “Commands,” “Schedule,” and “Jobs”) redirect to the wrong path.

For example, they go to “http://localhost/telescope/requests” where the project path after “localhost” is missing. It should actually be “http://localhost/my-project/telescope-project/public/telescope/requests.” Please guide me on how to configure this correctly.

Please guide me to configure correctly

ReactPHP memory problem with keep-alive connections

I have a API Rest developed with ReactPHP and FastRoute. If I call it from a web interfaz with header “Connection: keep-alive” the memory starts to increase until memory crash. I tried to change the header to “Connection: close” and there are not memory leaks.

Do you know why is this happening?
Can I disable keep-alive in my ReactPHP server?

Thanks

This is the code of my server

$server = new Server($loop, new ErrorHandler(), new JsonRequestDecoder(), new CorsMiddleware([
    'allow_origin' => [
        '*',
        'http://localhost:3000'
    ],
    'allow_methods'     => ['GET', 'POST', 'PUT', 'DELETE', 'HEAD', 'OPTIONS'],
    'allow_headers'     => ['DNT','X-Custom-Header','Keep-Alive','User-Agent','X-Requested-With','If-Modified-Since','Cache-Control','Content-Type','Content-Range','Range'],
    'expose_headers'    => ['DNT','X-Custom-Header','Keep-Alive','User-Agent','X-Requested-With','If-Modified-Since','Cache-Control','Content-Type','Content-Range','Range']
 
]), new Router($routes));

Fetch SQL table data once & keep running query on that table data locally instead of connecting to db every time in PHP [closed]

I’m trying to reduce the number of query done to database via PHP for a page that it repeatedly running query inside loop to fetch data.

Is there any way I can fetch the SQL table data locally once, and keep running query (if any) on that locally available pool of table data instead of having to connect to DB every time? This is causing lot of delay in page loading. Looking to optimize the same by reducing the DB connections.

Couldn’t find any solution on my research. Thought of using SQL Views but they too depend on frequent connections to DB. I’m looking to fetch data at once on page load, and keep running my other queries on the same selected data over and over instead of connecting to DB every time. The nested loops are taking too long and affecting the performance.

Deploying Laravel project on render web hosting service provider shows 500 error after adding Docker

The description of my laravel project:

"require": {
        "php": "^8.1",
        "guzzlehttp/guzzle": "^7.2",
        "itsgoingd/clockwork": "^5.1",
        "laravel/framework": "^10.10",
        "laravel/sanctum": "^3.3",
        "laravel/tinker": "^2.8"
    },
    "require-dev": {
        "fakerphp/faker": "^1.9.1",
        "laravel/pint": "^1.0",
        "laravel/sail": "^1.18",
        "mockery/mockery": "^1.4.4",
        "nunomaduro/collision": "^7.0",
        "phpunit/phpunit": "^10.1",
        "spatie/laravel-ignition": "^2.0"
    }

I have created files like

root/Dockerfile:

FROM richarvey/nginx-php-fpm:latest

COPY . .

# Image config
ENV SKIP_COMPOSER 1
ENV WEBROOT /var/www/html/public
ENV PHP_ERRORS_STDERR 1
ENV RUN_SCRIPTS 1
ENV REAL_IP_HEADER 1

# Laravel config
ENV APP_ENV production    //I dont know if I should add or remove this config because        
ENV APP_DEBUG false       //the project is still in the development phase and I don't 
ENV LOG_CHANNEL stderr    //know if I should keep APP_DEBUG to true

# Allow composer to run as root
ENV COMPOSER_ALLOW_SUPERUSER 1

CMD ["/start.sh"]

root/conf/ngnix/ngnix-site.conf:

server {
  # Render provisions and terminates SSL
  listen 80;

  # Make site accessible from http://localhost/
  server_name _;

  root /var/www/html/public;
  index index.html index.htm index.php;

  # Disable sendfile as per https://docs.vagrantup.com/v2/synced-folders/virtualbox.html
  sendfile off;

  # Add stdout logging
  error_log /dev/stdout info;
  access_log /dev/stdout;

  # block access to sensitive information about git
  location /.git {
    deny all;
    return 403;
  }

  add_header X-Frame-Options "SAMEORIGIN";
  add_header X-XSS-Protection "1; mode=block";
  add_header X-Content-Type-Options "nosniff";

  charset utf-8;

  location / {
      try_files $uri $uri/ /index.php?$query_string;
  }

  location = /favicon.ico { access_log off; log_not_found off; }
  location = /robots.txt  { access_log off; log_not_found off; }

  error_page 404 /index.php;

  location ~* .(jpg|jpeg|gif|png|css|js|ico|webp|tiff|ttf|svg)$ {
    expires 5d;
  }

  location ~ .php$ {
    fastcgi_split_path_info ^(.+.php)(/.+)$;
    fastcgi_pass unix:/var/run/php-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param SCRIPT_NAME $fastcgi_script_name;
    include fastcgi_params;
  }

  # deny access to . files
  location ~ /. {
    log_not_found off;
    deny all;
  }

  location ~ /.(?!well-known).* {
    deny all;
  }
}

root/scripts/00-laravel-deploy.sh:

#!/usr/bin/env bash
echo "Running composer"
composer global require hirak/prestissimo
composer install --no-dev --working-dir=/var/www/html

echo "generating application key..."
php artisan key:generate --show

echo "Caching config..."
php artisan config:cache

echo "Caching routes..."
php artisan route:cache

echo "Running migrations..."
php artisan migrate --force   //I do also have some seeders file too but I dont want to 
                              //add in it

root/.dockerignore:

/node_modules
/public/hot
/public/storage
/storage/*.key
/vendor
.env
.phpunit.result.cache
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log

For the database, I have created a POSTGRESQL in Render and I added the credentials in their environment variable file.

And with that, I have pushed in my git repo. These are the images that show how I have set up the project.

:https://imgur.com/a/EJiEmMy

Now from Render, it is telling me that the build is successful, yet I am seeing 500 error.

Which I still cannot figure out why.

Also, the application log details are shared in-> https://pastebin.com/ujdfBRxQ

Initially,I removed the conf part from Dockerfile, but the problem still remains the same.

“Error Encountered After PHP 8.3 Update on IIS Server”

Deprecated: Return type of PhpOfficePhpSpreadsheetWorksheetColumnIterator::current() should either be compatible with Iterator::current(): mixed, or the #[ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in C:inetpubwwwrootdev_iscomsordfulClassesPHPExcelvendorphpofficephpspreadsheetsrcPhpSpreadsheetWorksheetColumnIterator.php on line 135

Deprecated: Return type of PhpOfficePhpSpreadsheetWorksheetColumnIterator::next() should either be compatible with Iterator::next(): void, or the #[ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in C:inetpubwwwrootdev_iscomsordfulClassesPHPExcelvendorphpofficephpspreadsheetsrcPhpSpreadsheetWorksheetColumnIterator.php on line 153

Deprecated: Return type of PhpOfficePhpSpreadsheetWorksheetColumnIterator::key() should either be compatible with Iterator::key(): mixed, or the #[ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in C:inetpubwwwrootdev_iscomsordfulClassesPHPExcelvendorphpofficephpspreadsheetsrcPhpSpreadsheetWorksheetColumnIterator.php on line 145

Deprecated: Return type of PhpOfficePhpSpreadsheetWorksheetColumnIterator::valid() should either be compatible with Iterator::valid(): bool, or the #[ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in C:inetpubwwwrootdev_iscomsordfulClassesPHPExcelvendorphpofficephpspreadsheetsrcPhpSpreadsheetWorksheetColumnIterator.php on line 171

Deprecated: Return type of PhpOfficePhpSpreadsheetWorksheetColumnIterator::rewind() should either be compatible with Iterator::rewind(): void, or the #[ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in C:inetpubwwwrootdev_iscomsordfulClassesPHPExcelvendorphpofficephpspreadsheetsrcPhpSpreadsheetWorksheetColumnIterator.php on line 125

Deprecated: Return type of PhpOfficePhpSpreadsheetWorksheetIterator::current() should either be compatible with Iterator::current(): mixed, or the #[ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in C:inetpubwwwrootdev_iscomsordfulClassesPHPExcelvendorphpofficephpspreadsheetsrcPhpSpreadsheetWorksheetIterator.php on line 55

Deprecated: Return type of PhpOfficePhpSpreadsheetWorksheetIterator::next() should either be compatible with Iterator::next(): void, or the #[ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in C:inetpubwwwrootdev_iscomsordfulClassesPHPExcelvendorphpofficephpspreadsheetsrcPhpSpreadsheetWorksheetIterator.php on line 73

Deprecated: Return type of PhpOfficePhpSpreadsheetWorksheetIterator::key() should either be compatible with Iterator::key(): mixed, or the #[ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in C:inetpubwwwrootdev_iscomsordfulClassesPHPExcelvendorphpofficephpspreadsheetsrcPhpSpreadsheetWorksheetIterator.php on line 65

Deprecated: Return type of PhpOfficePhpSpreadsheetWorksheetIterator::valid() should either be compatible with Iterator::valid(): bool, or the #[ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in C:inetpubwwwrootdev_iscomsordfulClassesPHPExcelvendorphpofficephpspreadsheetsrcPhpSpreadsheetWorksheetIterator.php on line 83

Deprecated: Return type of PhpOfficePhpSpreadsheetWorksheetIterator::rewind() should either be compatible with Iterator::rewind(): void, or the #[ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in C:inetpubwwwrootdev_iscomsordfulClassesPHPExcelvendorphpofficephpspreadsheetsrcPhpSpreadsheetWorksheetIterator.php on line 45

Recently, I updated my PHP version to 8.3, and I’m encountering errors. I’m using an IIS server.

show woocommerce variable product as tab

I want to custmize woo single page with this design but unable to get same result. Show number of sales and other things but this is not working. I am using botiga theme with wordpress.

this is reference design
enter image description here

and this is i achived

enter image description here

PHP autoloader duplicate path

i want to learn autoloader in PHP but i loader duplicate my path to my files and its not working.

<?php


function myAutoLoader($class){
    $directories = [
        __DIR__ .  "/classes/account/",
        __DIR__ .  "/classes/database/",
    ];
    $extension = ".php";

    foreach ($directories as $directory){
        $fullPath = $directory . str_replace('\', '/', $class) . $extension;
        var_dump($fullPath);
        if(file_exists($fullPath)) {
            require_once $fullPath;
            return true;
        }
    }
    return false;
}

spl_autoload_register('myAutoLoader');

and my Classes, were i want get path:

<?php

namespace controllers;


use classesaccountRegisterAccount;

require_once __DIR__ . "/../includes/autoloader.php";

class RegisterController extends RegisterAccount

but path its duplicate:
string(94) “C:xampphtdocsreservationSystemincludes/classes/account/classes/account/RegisterAccount.php” string(95)

my directory structure is :
project/
├── classes/
│ ├── account/
|
___RegisterAccount.php
│ └── database/
│ └── Connect.php
└── includes/
└── autoloader.php

I searched for answers on youtube and sof but, did not find a solution.