Document how to use in a Symfony project
I'd love to be able to use this in a Symfony project. If you have the symfony CLI installed, here's a simple script to see the error. (I'm only putting the example in the controller to make it easier to see the error message). Since it's not lavarel, I also installed illuminate/support.
Thanks.
symfony new --webapp archetype-test && cd archetype-test
composer install
composer require ajthinking/archetype illuminate/support
cat > src/Controller/AppController.php <<'END'
<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Archetype\Facades\PHPFile;
class AppController extends AbstractController
{
#[Route('/', name: 'app_homepage')]
public function index()
{
// Create new class
PHPFile::make()->class('App\\Entity\\Product')
->use('Shippable')
->public()->property('stock', -1)
->save();
}
}
END
symfony server:start -d
symfony open:local
Hi, thanks for posting! Unfortunately Im not familiar with sympfony. There might be some issues that it depends on laravels app container, or other specifics.
Could you provide an example of how to set this up in lavarel? Or a demo repo with installation instructions?
It appears that you've done most of the hard work of integrating the php-nic library and generating the code, and the lavarel part is mostly a wrapper around those calls and loading the class. Although I'm not familiar with lavarel, if I had a working example I might be able to provide a similar wrapper but around Symfony.
Here is the where PHPFile is bootstrapped
However, this line might cause Issues using deploying outside Laravel: https://github.com/ajthinking/archetype/blob/291f5d40c040829467c23bf4cf35d8acb4398daf/src/Endpoints/PHP/PHPFileQueryBuilder.php#L56-L57
As that method app is from laravel.
I would love to help with this, but have no time right now. /ajthinking