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

Feature Request: Allow craft:class to use a template and define path to save the class #2

Closed
abishekrsrikaanth opened this issue Apr 15, 2019 · 9 comments
Assignees
Labels
enhancement New feature or request

Comments

@abishekrsrikaanth
Copy link

Can you add an enhancement to define a template using a path and also define a path to save the class?

@mikeerickson
Copy link
Owner

I am not sure what you mean?

If you execute

laravel-craftsman craft:class App/Services/Contacts/MyClass ...

The class will be created in

App
—Services
    —Contacts
         — MyClass

@mikeerickson
Copy link
Owner

I will update documentation to clarify this

If you are thinking of something else, please let me know

@mikeerickson
Copy link
Owner

@abishekrsrikaanth With regards to defining the path to the template, you can use the config.php path in the installed path of the laravel-craftsman app. Here you can customize the path to each of the various templates.

~/.composer/vendor/<username>/laravel-craftsman/builds/config.php
return [
    "templates" => [

        'class' => 'templates/class.user.mustache',

    ],
];

@abishekrsrikaanth
Copy link
Author

abishekrsrikaanth commented Apr 15, 2019

Thanks for clarifying the save path. That definitely helps. But my question about using a template was about setting the template using an argument instead of the config file. There are a variety of classes that one requires to create in addition to views, models, controllers, etc. Let's say for example FormRequests, Jobs, ApiResources that may use a custom traits or interfaces or extends abstract classes. If I create a few mustache templates within my project directory, it would be easier to do

> laravel-craftsman 
          craft:class App\Domains\Account\Jobs\OnCreateUser 
          --template="templates/sync.job.mustache"

This way we could have project specific templates instead of using the global templates.
And you don't have to change the template path on the config file every time you want a different template.
I hope that makes sense.

@mikeerickson
Copy link
Owner

I understand what you are asking and will add this as a request. I can see how this would be beneficial 🤓

@abishekrsrikaanth
Copy link
Author

Sound good. Look forward to this.

@mikeerickson mikeerickson self-assigned this Apr 17, 2019
@mikeerickson mikeerickson added the enhancement New feature or request label Apr 17, 2019
@mikeerickson
Copy link
Owner

@abishekrsrikaanth while considering this feature, you have defined 👎

  ...
  --template="templates/sync.job.mustache"
  ...

Are you thinkinig of project specific templates, or global templates (those available in all projects)

@mikeerickson
Copy link
Owner

@abishekrsrikaanth after thinking about this, I am going to implement using both, with default being the application templates directory. In addition, you define <project> which will use the current project directory.

laravel-craftsman craft:class --template "templates/templates/sync.job.mustache"
laravel-craftsman craft:class --template "<project>/templates/templates/sync.job.mustache"

@mikeerickson
Copy link
Owner

@abishekrsrikaanth This has been added in the latest release (version 1.1)

https://github.com/mikeerickson/laravel-craftsman/releases/tag/1.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants