Issue with WP_Session_Tokens::destroy() – Nothing happen

I have an issue with this code:

$manager = WP_Session_Tokens::get_instance(get_current_user_id());
$manager->destroy(0);

I want to destroy the session at index 0, but it’s not working. How can I properly remove a specific session?
If destroying a session is only possible with a token, how can I get the token of a specific session to remove it?

Fastest way to randomly shuffle an array based on probabilities in PHP?

I have an array with values and probabilities (or in PHP, keys and values):

Value   Probability
John    3
Peter   2
Paul    1

I want to shuffle this array but have the order be influenced by the probability. That is, on average John should appear at the top of the list half the time, Peter a third of the time, and Paul one sixth of the time. The average order over thousands of shuffles should be the one given above.

I have thought to

  1. Create an array in which each value appears as often as indicated by the probability:

    John
    John
    John
    Peter
    Peter
    Paul
    
  2. Shuffle this array, e.g.:

    John
    Paul
    Peter
    John
    John
    Peter
    
  3. Remove the duplicates, leaving the first instance:

    John
    Paul
    Peter
    

In PHP code this might look something like this:

$items = array(
    'John' => 3,
    'Peter' => 2,
    'Paul' => 1
);

$probabilities = array();
foreach($items as $item => $value){
    $interim = array_fill(1, $value, $item);
    $probabilities = array_merge($probabilities, $interim);
}

shuffle($probabilities);

$result = array_unique($probabilities);

print("<pre>".print_r($result,true)."</pre>");

Is there a faster way to do this?

The real array contains a few hundred values and this probability-based shuffling has to be done everytime a webpage is called, so it should be lightning quick.

I can’t receive events via reverb on the local network

I created an application with reverb where I made a simple channel and an event that receives a message and transmits it to the subscribers on the reverb channel. It turns out that when I tried to make a connection with the frontend in react using echo.js I ended up not receiving any type of information from the channel. How can I implement reverb correctly? The documentation does not have the information I am looking for.

Laravel Event:

<?php

namespace AppEvents;

use IlluminateBroadcastingChannel;
use IlluminateBroadcastingInteractsWithSockets;
use IlluminateBroadcastingPresenceChannel;
use IlluminateBroadcastingPrivateChannel;
use IlluminateContractsBroadcastingShouldBroadcast;
use IlluminateContractsBroadcastingShouldBroadcastNow;
use IlluminateFoundationEventsDispatchable;
use IlluminateQueueSerializesModels;

class Chat implements ShouldBroadcastNow
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    public $msg;
    /**
     * Create a new event instance.
     */
    public function __construct($msg)
    {
        //
        $this->msg = $msg;
    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return array<int, IlluminateBroadcastingChannel>
     */
    public function broadcastOn(): array
    {
        return [
            new Channel('chat'),
        ];
    }
}

Laravel Channel:

<?php

use IlluminateSupportFacadesBroadcast;

Broadcast::channel('App.Models.User.{id}', function ($user, $id) {
    return (int) $user->id === (int) $id;
});

Broadcast::channel('Chat', function () {
});

Call:

Route::get('/ws', function(){
    Broadcast(new Chat('test'));
});

Echo.js front-react

import Echo from 'laravel-echo';
import Pusher from 'pusher-js';

const echo = new Echo({
    broadcaster: 'pusher',
    key: process.env.REACT_APP_PUSHER_APP_KEY, // Chave do Pusher
    wsHost: '192.168.1.69', // Host do Reverb
    wsPort: 8080, // Porta do Reverb
    forceTLS: false, 
    disableStats: true,
});

export default echo;

app.js
“’
import React, { useEffect, useState } from ‘react’;
import echo from ‘./echo’; // Importe o Echo configurado

function App() {
const [mensagem, setMensagem] = useState(”);

useEffect(() => {
    // Ouvir um canal público
    echo.channel('chat')
        .listen('Chat', (e) => {
            setMensagem(e.mensagem); // Atualize o estado com a mensagem recebida
            console.log('Evento recebido:', e);
        });

    // Limpar a inscrição ao desmontar o componente
    return () => {
        echo.leaveChannel('canal-reverb');
    };
}, []);

return (
    <div>
        <h1>Mensagem Recebida:</h1>
        <p>{mensagem}</p>
    </div>
);

}

export default App;




I can successfully receive connections from the machine where the local server is located, but when I try to make connections with other machines, Reverb does not identify connections. 

I am trying to connect to Docusign through my WebApp and my JWT is failing – “kid” invalid

I have a web app in PHP, and JS for front-end. I am connecting to Dcusign through the JWT and exchanging it for an access token, but I keep getting this error:

Decoding JWT did not work

UnexpectedValueException: “kid” invalid,
unable to lookup correct key in
/html/htdocs/mrt_dgheorghe/vendor/firebase/php-jwt/src/JWT.php:477

The code for JWT looks like this:

$now = time();
$payload = [
    'iss' => $clientId,
    'sub' => $apiUserId,
    'aud' => 'account-d.docusign.com',
    'scope' => 'signature impersonation',
    'iat' => $now,
    'exp' => $now + 3600 // 1 hour expiration
];
$privateKey = file_get_contents($privateKeyFilePath);
$jwt = JWT::encode($payload, $privateKey, 'RS256', $keypairID); //kid
$publicKey = file_get_contents('publicKey.key');

try
{
    $decodedJWT = JWT::decode($jwt,$publicKey);
    print_r($decodedJWT);
    echo "This is the decoded JWT";
}
catch(Exception $e)
{
    echo "Decoding JWT did not work";
    print($e);

Is the kid the equivalent of the Docusign Keypair ID? I am manually transmitting it when encoding the JWT but I do not even know if it’s the right approach.

WordPress stylesheet not loading, css styles not appearing, docker compose

WordPress styles not loading. Used docker-compose to start nginx, mariadb & wordpress. Here is the configuration I’m using.

services:
  mysql:
    image: mariadb:latest
    container_name: wordpress-sql
    volumes:
      -  maria-db-wp:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wpadmin
      MYSQL_PASSWORD: wpadminpass
    restart: unless-stopped
    networks:
      - wordpress-vpc
  wordpress:
    image: wordpress:beta-php8.3-fpm-alpine
    container_name: wordpress-main
    volumes:
      - wp-vol-1:/var/www/html
    depends_on:
      - mysql
    environment:
      WORDPRESS_DB_HOST: mysql
      MYSQL_ROOT_PASSWORD: root
      WORDPRESS_DB_NAME: wordpress
      WORDPRESS_DB_USER: wpadmin
      WORDPRESS_DB_PASSWORD: wpadminpass
      WORDPRESS_TABLE_PREFIX: wp_
    restart: unless-stopped
    networks:
      - wordpress-vpc
  nginx:
    image: nginx:stable-alpine-perl
    container_name: nginx-wp
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf:ro
      - wp-vol-1:/var/www/html
    ports:
      - "80:80"
    networks:
      - wordpress-vpc
    restart: unless-stopped
    depends_on:
      - wordpress
  
networks:
  wordpress-vpc:
    driver: bridge
volumes:
  maria-db-wp:
  wp-vol-1:

Here are some screenshots

enter image description here

Here is the page source
enter image description here

I tried searching for these css stylesheets inside of my installation directory both in my local installation (which work correctly) & my docker volume directory, both have the same CSS sheets inside /wp-admin/css so doesnt seem like an installation issue?

This entire thing is fresh & the volumes defined in the dockerfile were created just before this docker compose.

network tab screenshots
network tab
network tab css response

console says
JQMIGRATE: Migrate is installed, version 3.4.1

Even in the sources the css/ css-files do come so …

How to get a value of post_meta table when running after_delete_post() in WordPress?

I have a custom post type table which is connected to the post meta table in wordpress. I need to run some tasks after a post is deleted. For that I use the WordPress hook after_delete_post.

Within my function I need to get access to the user id which is stored by a plugin in the post meta table. I tried to access this meta_value through $post->meta_key but it doesn’t work.

Before I tested it with the wp_trash_post hook where it worked. I don’t understand why I still have access to post->post_type but not to post->meta_key anymore?

add_action( 'after_delete_post', 'my_deleted_post', 10, 2 );
    function my_deleted_post($post_id,$post) {
    if ( $post->post_type == 'review') {
        $meta_value=$post->linked_user_id;
    // some stuff to do with $meta_value after post is deleted
    }
    }

I cloned this laravel project and I run “composer install” which keeps failing

Install of srmklive/paypal failed

In GitDownloader.php line 509:
Failed to execute git checkout
1ddc49fd836a4785933ab953452152f3fedbac63 — && git reset –hard
1ddc49fd836a4785933ab953452152f3fedbac63 —

error: The following untracked working tree files would be overwritten
by checkout:

I tried to check whether the version is the cause of this issue and I downgraded and upgraded it respectively to see which could solve the issue but all my effort proved abortive.

What could be the issue here?

codeigniter 3 A PHP Error was encountered [duplicate]

A PHP Error was encountered
Severity: 8192

Message: Creation of dynamic property CI_URI::$config is deprecated

Filename: core/URI.php

Line Number: 101

Backtrace:

File: C:xampphtdocsSimple-KasirBarang-Codecodeigniter3-masterindex.php
Line: 315
Function: require_once

How to run the php inside an XML file?

I’ve been tasked with editing the PHP inside an XML file. I had no idea this was a thing people did, and I wish they didn’t, because I don’t understand it. So I tried to look it up and I came across this question and answer about how to add php to an XML file.

It seemed like a really promising QA, because the format suggested by the top answer (using “<![CDATA[” and “]]>” around the PHP is exactly what’s happening in the xml file I’ve been tasked to edit.

But now my question is… How the heck do I run the thing? It obviously can’t run just by doing php -S localhost:8000, because it’s not php. there is no <?php or ?>, so the interpreter wouldn’t know what was php and what wasn’t.

Why is there php in the xml file? and what do now that it’s already happened?

Here’s a minimal example (not the actual file I’m working with).

<?xml version="1.0" encoding="ISO-8859-1"?>
<product productid="blah blah blah" active="1">
    <title>blah blah</title>
    <description><![CDATA[yadda yadda]]></description>
    <version>1.3</version>
    <url><![CDATA[http://www.foobar.com/mods/misc.php?do=producthelp&pid=hashbaz]]></url>
    <versioncheckurl><![CDATA[http://www.foobar.com/mods/misc.php?do=productcheck&pid=hashbaz]]></versioncheckurl>
    <dependencies>
        <dependency dependencytype="vbulletin" minversion="3.5" maxversion="5.0.0" />
    </dependencies>
    <codes>
    </codes>
    <templates>
    </templates>
    <stylevardfns>
    </stylevardfns>
    <stylevars>
    </stylevars>
    <plugins>
        <plugin active="1" executionorder="5">
            <title>some plugin</title>
            <hookname>some hook name</hookname>
            <phpcode><![CDATA[ echo "and now we're doing php for some reason???" . $qux; ]]></phpcode>
        </plugin>
    </plugins>
</products>

Use avatar in other model

I have a model for Product and a related ProductAsset model for images, videos or documents related to the product. What I want to achieve is to let the user upload the main image as a product asset (flag is_primary=true) in the same form as the rest of the information.

Here is my Product model:

    namespace AppModels;
    
    use IlluminateDatabaseEloquentModel;
    
    class Product extends Model
    {
        protected $fillable = [
            'name',
            'description',
            'is_active',
            'category_id',
        ];
    
        public function menus()
        {
            return $this->belongsToMany(Catalog::class);
        }
    
        public function category()
        {
            return $this->belongsTo(Category::class);
        }
    
        public function assets()
        {
            return $this->hasMany(ProductAsset::class);
        }
    
        public function allergens()
        {
            return $this->belongsToMany(Allergen::class);
        }
    
        public function mainImage()
        {
            return $this->assets()->where('is_primary', true)->first();
        }
    }

And my ProductAsset model:

    namespace AppModels;
    
    use IlluminateDatabaseEloquentModel;
    
    class ProductAsset extends Model
    {
        protected $fillable = [
            'name',
            'type',
            'path',
            'is_primary',
            'product_id',
        ];
    
        public function product()
        {
            return $this->belongsTo(Product::class);
        }
    }

In my Filament/Resources/ProductResource.php, I have the following in the form() method:

    public static function form(Form $form): Form
        {
            return $form
                ->columns(12)
                ->schema([
                    Group::make()->schema([
                        FileUpload::make('image')
                            ->label('Imagen')
                            ->avatar()
                            ->placeholder(function ($record) {
                                if ($record && $record->mainImage()) {
                                    $main_image = $record->mainImage();
                                    $imagePath = asset("/storage/" . $main_image->path);
                                    return <<<HTML
                                        <img src="$imagePath" alt="Imagen principal" class="cropper-crop-box">
                                    HTML;
                                }
                            })
                            ->required(),
                    ])
                    ->columnSpan(2),
                    Group::make()->schema([
                        TextInput::make('name')
                            ->label('Nombre')
                            ->required(),
                        Textarea::make('description')
                            ->label('Descripción')
                            ->required(),
                        Select::make('category_id')
                            ->label('Categoría')
                            ->relationship(name: 'category', titleAttribute: 'name')
                            ->required(),
                        Toggle::make('is_active')
                            ->default(true)
                            ->label('Activo'),
                    ])
                    ->columnSpan(10),
                ]);
        }

So, in the Filament/Resources/CreateProduct.php I handle the file using the mutateFormDataBeforeCreate() and afterCreate() method:

    protected function mutateFormDataBeforeCreate(array $data): array
    {
        $main_image = $data['image'];
        unset($data['image']);

        $this->creatingProductAsset = $main_image;

        return $data;
    }

    protected function afterCreate()
    {
        if ($this->creatingProductAsset) {
            ProductAsset::create([
                'name' => 'Imagen principal',
                'type' => 'image',
                'path' => $this->creatingProductAsset,
                'product_id' => $this->record->id,
                'is_primary' => true, // 
            ]);
        }
    }

So far so good! My image is uploading, and the related record is created successfully.

Here is the problem: when I enter the view/edit page, it’ll show the image as a placeholder but it won’t attatch the value to the field. Of course, I won’t be able to save changes until I upload a new one. That’s logic since I’m showing the actual image as a placeholder instead of loading it into the field’s state.

Now, my question is, how do I bind the already uploaded image as the field value so the record can be updated without uploading a new one? How should I use the ->afterStateHydrated method in the field to link the actual image instead of showing it as a placeholder?

Than you all in advance!

telephone validation opencart

Opencart 2,3,0,2, Journal 3

I checked journal/skin/checkout telephone as required. (If I do hidden, it works but required is not)

catalog/controller/account/register.php

I have solved checking telephone number 10 digit and only numeric with the code below:

if (
  (utf8_strlen($this->request->post['telephone']) < 9) || 
  (utf8_strlen($this->request->post['telephone']) > 11) || 
  preg_match('/[^d]/is', $this->request->post['telephone'])
) {
  $this->error['telephone'] = $this->language->get('error_telephone');

but catalog/controller/checkout/register.php is not solved in this way.

Some forums say that telephone can be changed in settings which there is not any option in 2,3,0,2.

last name, first name validation works perfectly with the code below but language does not work in catalog/controller/checkout/register.php

if (
  (utf8_strlen(trim($this->request->post['telephone'])) < 1) || 
  (utf8_strlen(trim($this->request->post['telephone'])) > 32)
) {
  $json['error']['telephone'] = $this->language->get('error_telephone');
}

What did I miss?

i have a weird error in laravel i got this error Svg by name “heroic on-o-rectangle-stack” from set “default” not found

Svg by name “heroic on-o-rectangle-stack” from set “default” not found.

BladeUIIconsExceptionsSvgNotFound
:13
missing

BladeUIIconsFactory
:177
contents

BladeUIIconsFactory
:128
svg

C:laragonwwwfarm-app-adminvendorblade-ui-kitblade-iconssrchelpers.php
:11
svg

C:laragonwwwfarm-app-adminvendorfilamentsupportresourcesviewscomponentsicon.blade.php
:24
require

IlluminateFilesystemFilesystem
:123
IlluminateFilesystem{closure}

IlluminateFilesystemFilesystem
:124
getRequire

IlluminateViewEnginesPhpEngine
:58
evaluatePath

LivewireMechanismsExtendBladeExtendedCompilerEngine
:22
evaluatePath

IlluminateViewEnginesCompilerEngine
:75
get

LivewireMechanismsExtendBladeExtendedCompilerEngine
:10
get

IlluminateViewView
:209
getContents

IlluminateViewView
:192
renderContents

IlluminateViewView
:161
render

IlluminateViewConcernsManagesComponents
:103
renderComponent

C:laragonwwwfarm-app-adminvendorfilamentfilamentresourcesviewscomponentssidebaritem.blade.php
:74
require

IlluminateFilesystemFilesystem
:123
IlluminateFilesystem{closure}

IlluminateFilesystemFilesystem
:124
getRequire

IlluminateViewEnginesPhpEngine
:58
evaluatePath

LivewireMechanismsExtendBladeExtendedCompilerEngine
:22
evaluatePath

IlluminateViewEnginesCompilerEngine
:75
get

LivewireMechanismsExtendBladeExtendedCompilerEngine
:10
get

IlluminateViewView
:209
getContents

IlluminateViewView
:192
renderContents

IlluminateViewView
:161
render

IlluminateViewConcernsManagesComponents
:103
renderComponent

C:laragonwwwfarm-app-adminvendorfilamentfilamentresourcesviewscomponentssidebargroup.blade.php
:222
require

IlluminateFilesystemFilesystem
:123
IlluminateFilesystem{closure}

IlluminateFilesystemFilesystem
:124
getRequire

IlluminateViewEnginesPhpEngine
:58
evaluatePath

LivewireMechanismsExtendBladeExtendedCompilerEngine
:22
evaluatePath

IlluminateViewEnginesCompilerEngine
:75
get

LivewireMechanismsExtendBladeExtendedCompilerEngine
:10
get

IlluminateViewView
:209
getContents

IlluminateViewView
:192
renderContents

IlluminateViewView
:161
render

IlluminateViewConcernsManagesComponents
:103
renderComponent

C:laragonwwwfarm-app-adminvendorfilamentfilamentresourcesviewscomponentssidebarindex.blade.php
:129
require

IlluminateFilesystemFilesystem
:123
IlluminateFilesystem{closure}

IlluminateFilesystemFilesystem
:124
getRequire

IlluminateViewEnginesPhpEngine
:58
evaluatePath

LivewireMechanismsExtendBladeExtendedCompilerEngine
:22
evaluatePath

IlluminateViewEnginesCompilerEngine
:75
get

LivewireMechanismsExtendBladeExtendedCompilerEngine
:10
get

IlluminateViewView
:209
getContents

IlluminateViewView
:192
renderContents

IlluminateViewView
:161
render

IlluminateViewConcernsManagesComponents
:103
renderComponent

C:laragonwwwfarm-app-adminvendorfilamentfilamentresourcesviewscomponentslayoutindex.blade.php
:93
require

IlluminateFilesystemFilesystem
:123
IlluminateFilesystem{closure}

IlluminateFilesystemFilesystem
:124
getRequire

IlluminateViewEnginesPhpEngine
:58
evaluatePath

LivewireMechanismsExtendBladeExtendedCompilerEngine
:22
evaluatePath

IlluminateViewEnginesCompilerEngine
:75
get

LivewireMechanismsExtendBladeExtendedCompilerEngine
:10
get

IlluminateViewView
:209
getContents

IlluminateViewView
:192
renderContents

IlluminateViewView
:161
render

IlluminateViewConcernsManagesComponents
:103
renderComponent

C:laragonwwwfarm-app-adminstorageframeworkviews4943bc92ebba41e8b0e508149542e0ad.blade.php
:16
require

IlluminateFilesystemFilesystem
:123
IlluminateFilesystem{closure}

IlluminateFilesystemFilesystem
:124
getRequire

IlluminateViewEnginesPhpEngine
:58
evaluatePath

LivewireMechanismsExtendBladeExtendedCompilerEngine
:22
evaluatePath

IlluminateViewEnginesCompilerEngine
:75
get

LivewireMechanismsExtendBladeExtendedCompilerEngine
:10
get

IlluminateViewView
:209
getContents

IlluminateViewView
:192
renderContents

IlluminateViewView
:161
render

IlluminateViewCompilersBladeCompiler
:337
render

IlluminateSupportFacadesFacade
:361
__callStatic

LivewireFeaturesSupportPageComponentsSupportPageComponents
:153
renderContentsIntoLayout

LivewireFeaturesSupportPageComponentsHandlesPageComponents
:24
__invoke

IlluminateRoutingControllerDispatcher
:47
dispatch

IlluminateRoutingRoute
:266
runController

IlluminateRoutingRoute
:212
run

IlluminateRoutingRouter
:808
IlluminateRouting{closure}

IlluminatePipelinePipeline
:170
IlluminatePipeline{closure}

FilamentHttpMiddlewareDispatchServingFilamentEvent
:15
handle

IlluminatePipelinePipeline
:209
IlluminatePipeline{closure}

FilamentHttpMiddlewareDisableBladeIconComponents
:14
handle

IlluminatePipelinePipeline
:209
IlluminatePipeline{closure}

IlluminateRoutingMiddlewareSubstituteBindings
:51
handle

IlluminatePipelinePipeline
:209
IlluminatePipeline{closure}

IlluminateFoundationHttpMiddlewareVerifyCsrfToken
:88
handle

IlluminatePipelinePipeline
:209
IlluminatePipeline{closure}

IlluminateSessionMiddlewareAuthenticateSession
:67
handle

IlluminatePipelinePipeline
:209
IlluminatePipeline{closure}

IlluminateAuthMiddlewareAuthenticate
:64
handle

IlluminatePipelinePipeline
:209
IlluminatePipeline{closure}

IlluminateViewMiddlewareShareErrorsFromSession
:49
handle

IlluminatePipelinePipeline
:209
IlluminatePipeline{closure}

IlluminateSessionMiddlewareStartSession
:121
handleStatefulRequest

IlluminateSessionMiddlewareStartSession
:64
handle

IlluminatePipelinePipeline
:209
IlluminatePipeline{closure}

IlluminateCookieMiddlewareAddQueuedCookiesToResponse
:37
handle

IlluminatePipelinePipeline
:209
IlluminatePipeline{closure}

IlluminateCookieMiddlewareEncryptCookies
:75
handle

IlluminatePipelinePipeline
:209
IlluminatePipeline{closure}

FilamentHttpMiddlewareSetUpPanel
:19
handle

IlluminatePipelinePipeline
:209
IlluminatePipeline{closure}

IlluminatePipelinePipeline
:127
then

IlluminateRoutingRouter
:807
runRouteWithinStack

IlluminateRoutingRouter
:786
runRoute

IlluminateRoutingRouter
:750
dispatchToRoute

IlluminateRoutingRouter
:739
dispatch

IlluminateFoundationHttpKernel
:201
IlluminateFoundationHttp{closure}

IlluminatePipelinePipeline
:170
IlluminatePipeline{closure}

LivewireFeaturesSupportDisablingBackButtonCacheDisableBackButtonCacheMiddleware
:19
handle

IlluminatePipelinePipeline
:209
IlluminatePipeline{closure}

IlluminateFoundationHttpMiddlewareTransformsRequest
:21
handle

IlluminateFoundationHttpMiddlewareConvertEmptyStringsToNull
:31
handle

IlluminatePipelinePipeline
:209
IlluminatePipeline{closure}

IlluminateFoundationHttpMiddlewareTransformsRequest
:21
handle

IlluminateFoundationHttpMiddlewareTrimStrings
:51
handle

IlluminatePipelinePipeline
:209
IlluminatePipeline{closure}

IlluminateHttpMiddlewareValidatePostSize
:27
handle

IlluminatePipelinePipeline
:209
IlluminatePipeline{closure}

IlluminateFoundationHttpMiddlewarePreventRequestsDuringMaintenance
:110
handle

IlluminatePipelinePipeline
:209
IlluminatePipeline{closure}

IlluminateHttpMiddlewareHandleCors
:49
handle

IlluminatePipelinePipeline
:209
IlluminatePipeline{closure}

IlluminateHttpMiddlewareTrustProxies
:58
handle

IlluminatePipelinePipeline
:209
IlluminatePipeline{closure}

IlluminateFoundationHttpMiddlewareInvokeDeferredCallbacks
:22
handle

IlluminatePipelinePipeline
:209
IlluminatePipeline{closure}

IlluminatePipelinePipeline
:127
then

IlluminateFoundationHttpKernel
:176
sendRequestThroughRouter

IlluminateFoundationHttpKernel
:145
handle

IlluminateFoundationApplication
:1193
handleRequest

C:laragonwwwfarm-app-adminpublicindex.php
:17
C:laragonwwwfarm-app-adminvendorblade-ui-kitblade-iconssrcExceptionsSvgNotFound.php :13

final class SvgNotFound extends Exception
{
public static function missing(string $set, string $name): self
{
return new self(“Svg by name “$name” from set “$set” not found.”);
}
}

Docusign Rest API: Creating an Envelope Using JWT Credentials

I am trying to upgrade some older code that uses Docusign’s username/password method of authentication for their Rest API to the newer OAuth version.
We’re using this for an automated service so JWT makes sense. Our existing code uses a prebuilt template in the Docusign account and populates it and sends it to the recipient. I have created a JWT Bearer Token and tried implementing it using cURL but I just get the response “false”. I am at a loss here. Docusign hasn’t been much help so far, their documentation is overwhelming. This runs in a WordPress functions.php file, it should be simple. i worked for years the old way.

    $fields        = [];
    $initials      = [];
    $checkboxes    = [];
    $recipients    = ['[email protected]'];
    $templateID    = "2ce6c87b-****";
    $accountId     = '0cec5847-****';
    $integratorKey = "d2c3fbe6-****";

     $data = array(
        'accountId' => $accountID,
        'templateId' => $templateID,
        'templateRoles' => $recipients,
        'emailSubject' => 'Important Forms',
        'status' => 'sent',
    );

    $data_string = json_encode($data);

    $curl = curl_init();

    curl_setopt_array($curl, array(
        CURLOPT_URL => ' https://demo.docusign.net/restapi/v2.1/accounts/123456789/envelopes',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_POST => true,
        CURLOPT_POSTFIELDS => $data_string,
        CURLOPT_HTTPHEADER => array ('Authorization: Bearer eyJ0****'),
    ));

    $response = curl_exec($curl);
    $status = curl_getinfo($curl, CURLINFO_HTTP_CODE);

    echo json_encode($response);

    curl_close($curl);

I am expecting some response from the cUrl call, even a 404. I literally get “false”.

Custom Herd/Valet Drivers for Resolving URL Paths in Vanilla PHP Projects

I encountered an issue where paths couldn’t be resolved properly in my vanilla PHP projects using Laravel Herd. The system would only recognize index.php files. For example, when accessing http://x.test/case-studies, it wouldn’t resolve to http://x.test/case-studies.php, even though that was the expected behavior.

To address this, I implemented a custom driver that fixed the issue, allowing the system to correctly resolve paths without requiring the .php extension. However, now when accessing http://x.test/services/, it should automatically route to http://x.test/services/index.php. Instead, I’m encountering a 404 error.

Error 1

2025/03/05 10:45:18 [error] 90478#1248117: *34 “Users/jack-brogan/Herd/x/html/services//index.html” is not found (2: No such file or directory), client: 127.0.0.1, server: , request: “GET /services/ HTTP/1.1”, upstream: “fastcgi://unix:/Users/jack-brogan/Library/Application Support/Herd/herd.sock”, host: “x.test”, referrer: “

I’m unsure as to why its being resolved with two forward slashes at the end of Users/jack-brogan/Herd/x/html/services// and also why its looking for the index.html and not index.php.

Error 2

2025/03/05 10:45:18 [error] 90478#1248117: *34 FastCGI sent in stderr: “PHP message: Servers is truePHP message: Current site path: /Users/jack-brogan/Herd/x/htmlPHP message: Current URI: /favicon.icoPHP message: Raw URI: /favicon.icoPHP message: sitepath 1: /Users/jack-brogan/Herd/x/html/favicon.ico.phpPHP message: sitepath 2: /Users/jack-brogan/Herd/x/html/favicon.ico/index.php” while reading response header from upstream, client: 127.0.0.1, server: , request: “GET /favicon.ico HTTP/1.1”, upstream: “fastcgi://unix:/Users/jack-brogan/Library/Application Support/Herd/herd.sock:”, host: “x.test”, referrer: “http://x.test/services/”

Driver

// namespace ValetDrivers;

use ValetDriversValetDriver;

class LocalValetDriver extends ValetDriver
{
    /**
     * Determine if the driver serves the request.
     */
    public function serves(string $sitePath, string $siteName, string $uri): bool
    {
        if (file_exists($sitePath . '/index.php')) {
            return true;
        }
        return true;
        // return file_exists($sitePath . $uri . '.php');
    }

    /**
     * Resolve the incoming request to a valid PHP script.
     */
    public function isStaticFile($sitePath, $siteName, $uri)
    {
        if (file_exists($staticFilePath = $sitePath . $uri)) {
            return $staticFilePath;
        }

        return false;
    }

    /**
     * Directs Nginx to the correct file.
     */
    public function frontControllerPath(string $sitePath, string $siteName, string $uri): string
    {

        error_log("Current site path: " . $sitePath);
        error_log("Current URI: " . $uri);
        error_log("Raw URI: " . $_SERVER['REQUEST_URI']);
        
        // Check if request is for a PHP file
        if (file_exists($sitePath . $uri . '.php')) {
            return $sitePath . $uri . '.php';
        }

        // Default to index.php if no other match is found
        return $sitePath . $uri . '/index.php'; // Ensure correct path to index.php
    }
}

It seems to be correctly going through the serves method but the issue is with the frontControllerPath.

Image in Laravel bug

my problem : i try to show the image in Laravel using the following code


        
   @foreach($data as $dat)
    <p>{{ $dat->name }}</p>
    <hr>
    <img src="{{ Storage::url($dat->avatar) }}" alt="">
    @endforeach 
  • i have linked the storage with the public

  • this how i save the image to data base with other data

public function createUser(CreateUserRequest $request){
        
        // dd($request);
    
        if($request->hasFile('avatar')){
            $image = $request->avatar;
            $path = Storage::disk('public')->put('avatar/',$request->file('avatar'));
            $userData = $request->all();
            $userData['avatar'] = $path;
            
            User::create($userData);
            return redirect()->back()->with('success_message','Success');
        }

        User::create($request->all());
            return redirect()->back()->with('success_message','Success');
        }
  • this is the string saved into data base
avatar/CU0TjohsMMm9VmmI1T3s1T1vUJkGjnXFlbvWejPT.jpg

the problem that i try the same code on my laptop the image showed correctly while on the pc i don’t know what is wrong