I created two classes
teste.php
<?php
namespace Projeto;
use Pai\classepai;
//include 'classepai.php';
class teste extends classePai
{
public function __construct()
{
echo 'classe teste<br>';
}
}
and
classepai.php
<?php
namespace Pai;
class classepai
{
public function __construct()
{
echo 'classe pai<br>';
}
}
it returns me an error UNLESS I uncomment include 'classepai.php';
Then I have this class from Laravel (php framework)
<?php
namespace App\Http;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
class Kernel extends HttpKernel
{...}
My question is how can HttpKernel
be extended WITHOUT BEING INCLUDED.
HttpKernel
is required in composer.json
and in code it's included using autoload.php
. That's why you don't need to include HttpKernel
manually. If you want to do same on classeapi
you should add it into composer.json
autoload
.psr-4
section using namespace
and folder location.
Example:
{
"autoload": {
"psr-4": {
"App\\": "app/",
"Pai\\": "packages/pai/src",
}
}
}
Then run command composer dump-autoload
and you will be able to use your classeapi
like so: Pai\classeapi