Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document how to use in a Symfony project #83

Open
tacman opened this issue Dec 4, 2023 · 3 comments
Open

Document how to use in a Symfony project #83

tacman opened this issue Dec 4, 2023 · 3 comments
Labels
help wanted Extra attention is needed

Comments

@tacman
Copy link

tacman commented Dec 4, 2023

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
@ajthinking ajthinking added the help wanted Extra attention is needed label Dec 4, 2023
@ajthinking
Copy link
Owner

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.

@tacman
Copy link
Author

tacman commented Dec 5, 2023

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.

@ajinvise
Copy link

ajinvise commented Dec 5, 2023

Here is the where PHPFile is bootstrapped

However, this line might cause Issues using deploying outside Laravel:

return app()->make($type)->load($filePath);
});

As that method app is from laravel.

I would love to help with this, but have no time right now. /ajthinking

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants