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

[11.x] Add format artisan command #52572

Closed
wants to merge 1 commit into from
Closed

[11.x] Add format artisan command #52572

wants to merge 1 commit into from

Conversation

1weiho
Copy link
Contributor

@1weiho 1weiho commented Aug 25, 2024

Because Laravel Pint has been built into the Laravel framework in the recent release, this PR provides a new artisan command: php artisan format, offering developers a more convenient and intuitive way to format code.

CleanShot.2024-08-25.at.23.37.31.mp4

Usage

The command's options all refer to the https://laravel.com/docs/11.x/pint#running-pint file, and the usage method is the same.

Format all files

php artisan format

Format specific files or directories

php artisan format app/Models
php artisan format app/Models/User.php

Format and display the updated list and detailed changes

php artisan format -v

Inspection without changes

php artisan format --test

Format only uncommitted files

php artisan format --dirty

@milwad-dev
Copy link
Contributor

I think using vendor dir is the best way:

.\vendor\bin\pint

But if you want to use artisan, you can create a command in your project.

@1weiho
Copy link
Contributor Author

1weiho commented Aug 26, 2024

I think using vendor dir is the best way:

.\vendor\bin\pint

But if you want to use artisan, you can create a command in your project.

I completely agree, and I also always use the vendor directory myself. My point is that for some beginner Laravel developers, they might not easily discover Pint, but code formatting is a very important feature. They might be more familiar with commands starting with php artisan, and could even guess that format represents formatting. So, this command would be more user-friendly and intuitive for them.

@jorqensen
Copy link

jorqensen commented Aug 26, 2024

Because Laravel Pint has been built into the Laravel framework in the recent release

Worth noting that it's only a dev dependency on the app skeleton.

I think people should leverage aliases in their shell of choice instead.

@taylorotwell
Copy link
Member

Thanks for your pull request to Laravel!

Unfortunately, I'm going to delay merging this code for now. To preserve our ability to adequately maintain the framework, we need to be very careful regarding the amount of code we include.

If applicable, please consider releasing your code as a package so that the community can still take advantage of your contributions!

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

Successfully merging this pull request may close these issues.

4 participants