src/Consoles/BaseCommand.php
public function addingNamespaceInComposer($namespace, $path, $output = 'composer.json')
    {
        $file = base_path('composer.json');
        $data = json_decode($this->filesystem->get($file), true);
        
        $rootStub = $this->config->get('tie.stubs.root');
        if(is_array($rootStub)) {
            $rootStub = data_get($this->config->get($rootStub), 'path',  '');
        }

        $path = str_replace(base_path().'/', '', $path) . '/' . $rootStub;

        $data["autoload"]["psr-4"] = array_merge($data["autoload"]["psr-4"], [ $namespace => $path ]);
        $this->filesystem->put(base_path($output), json_encode($data, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
    }
public function addingNamespaceInComposer($namespace, $path, $output = 'composer.json')
    {
        $file = base_path('composer.json');
        $data = json_decode($this->filesystem->get($file), true);
        
        $rootStub = $this->config->get('tie.stubs.root');
        if(is_array($rootStub)) {
            $rootStub = data_get($this->config->get($rootStub), 'path',  '');
        }

        $path = str_replace(base_path().'/', '', $path) . '/' . $rootStub;

        $data["autoload"]["psr-4"] = array_merge($data["autoload"]["psr-4"], [ $namespace => $path ]);
        $this->filesystem->put(base_path($output), json_encode($data, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
    }
public function addingNamespaceInComposer ( $ namespace , $ path , $ output = 'composer.json' ) { $ file = base_path ( 'composer.json' ) ; $ data = json_decode ( $ this -> filesystem -> get ( $ file ) , true ) ; $ rootStub = $ this -> config -> get ( 'tie.stubs.root' ) ; if ( is_array ( $ rootStub ) ) { $ rootStub = data_get ( $ this -> config -> get ( $ rootStub ) , 'path' , '' ) ; } $ path = str_replace ( base_path ( ) . '/' , '' , $ path ) . '/' . $ rootStub ; $ data [ "autoload" ] [ "psr-4" ] = array_merge ( $ data [ "autoload" ] [ "psr-4" ] , [ $ namespace => $ path ] ) ; $ this -> filesystem -> put ( base_path ( $ output ) , json_encode ( $ data , JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT ) ) ; }
Package namespace adding in composer

@param $namespace
@param $path
@param string $output
@internal param $key
Package namespace adding in composer