Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

t0berius's avatar

overwriting package code

I'm using for example a captcha library inside my laravel based application, the captcha was included using composer.

Since some of the config is not included inside the .conf file of the package itself, I would need to edit some functions of the package code itself.

What's the best way to do so, since editing code inside the package (vendor) dir is a bad idea in general.

I'm using

https://github.com/igoshev/laravel-captcha/tree/2.1

And I would need to overwrite the render() function:

<?php

namespace Igoshev\Captcha\Captcha\Generator;

class GeneratorWaves extends AbstractGenerator implements GeneratorInterface
{
    public function render($str, $params){

    }
}

What's the most proven way to do so? And where to place the overwriting code?

0 likes
1 reply
bestmomo's avatar
bestmomo
Best Answer
Level 52

hi,

I see in config file that you can choose your generator :

/*
|--------------------------------------------------------------------------
| Captcha generator.
|--------------------------------------------------------------------------
| Must implement GeneratorInterface.
|
*/
'generator' => \Igoshev\Captcha\Captcha\Generator\GeneratorWaves::class,

So you can create your own generator et change config to select it.

1 like

Please or to participate in this conversation.