Giter VIP home page Giter VIP logo

Comments (5)

skyronic avatar skyronic commented on August 17, 2024

Thanks for the suggestion! I'll see if it's possible without too much effort since I'm a little busy with work.

What kind of paths/use cases did you have in mind?

from laravel-file-generator.

AEK-BKF avatar AEK-BKF commented on August 17, 2024

Thanks for quick answer !
It's just the project root path '/'
So you can create any file in any folder into the project folder

from laravel-file-generator.

AEK-BKF avatar AEK-BKF commented on August 17, 2024

Hi, Any update ? :)

from laravel-file-generator.

skyronic avatar skyronic commented on August 17, 2024

Hey I spent some time trying to get this started, and turns out it's already possible, I had totally forgotten this feature existed:

https://github.com/skyronic/laravel-file-generator#getting-a-namespace-from-path

If you want to have a file that goes to "custom/MyClass.php", which lives in CustomNamespace simply do this:

php artisan generate:new php__custom

This will create a file resources/boilerplates/php__custom.boilerplate.txt

I've set up the file like this:

{
   "name": "My custom template",
   "out": "custom/{{ $name }}.php",
   "params": {
   }
}
---

<?php

namespace {{ Format::getNamespace($path, "custom", "CustomNamespace") }};

class {{ Format::baseName($name) }} {
    public function __construct () {

    }
}

Running php artisan generate php:custom MyClass gives you:

<?php

namespace CustomNamespace;

class MyClass {
    public function __construct () {

    }
}

You should be able to make it work with most scenarios by tweaking the formatNamespace function call. Hopefully this solves your issue. Please feel free to re-open issue if you still have problems.

from laravel-file-generator.

AEK-BKF avatar AEK-BKF commented on August 17, 2024

Thank you so much :)))))

from laravel-file-generator.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.