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

[5.x] - Add kickstart option #379

Closed
wants to merge 1 commit into from

Conversation

jhavenz
Copy link

@jhavenz jhavenz commented Dec 26, 2024

Laravel Installer Enhancement: --kickstart Option

Overview

This PR introduces a new --kickstart option to the Laravel installer, designed to streamline the initial development process by providing pre-configured application templates.

Since this feature leverages the power of the laravel-shift/blueprint package, the user is up-and-running with a non-trivial, fully functional application in a matter of seconds.

For the common use case where a developer needs to quickly run code to test a feature they're working on, try out a 3rd party library, test a library they're working on, fetch data from a REST API, etc. this option is a extremely convenient!

A few more cases I can think of regarding teaching/learning Laravel, this option:

a. Provides a starting point for more advanced Laravel tutorials
b. Allows teachers to start from scratch in a video tutorial, and cover almost any simple-to-advanced feature very rapidly (the student gets to see every step along the way too)
c. Can be used for specific documentation scenarios
d. The developer might be stuck in the depths of some gnarly code and needs a clean slate to test out some logic they're working on

It's also worth mentioning that Ruby on Rails is doing something very similar in their intro video.


Key Features

Ready-made Templates To Choose From

Blog Template:

Example:

laravel new my-blog --kickstart=blog

This is the simplest option to choose from.

2 models are included:

  • Post
  • Comment

Relationship types included:

  • belongsTo
  • hasMany
Generates the following files:

controllers and controller tests discussed below

- database/factories/PodcastFactory.php
- database/factories/EpisodeFactory.php
- database/factories/GenreFactory.php
- database/factories/GenrePodcastFactory.php
- database/migrations/<timestamp>_create_podcasts_table.php
- database/migrations/<timestamp>_create_episodes_table.php
- database/migrations/<timestamp>_create_genres_table.php
- database/migrations/<timestamp>_create_genre_podcast_table.php
- app/Models/Podcast.php
- app/Models/Episode.php
- app/Models/Genre.php
- app/Models/GenrePodcast.php
- database/seeders/KickstartSeeder.php

Podcast Template:

Example:

laravel new my-podcast --kickstart=podcast

The option gets a little more complex, so it's an 'intermediate' option.

3 standard models, and 1 pivot model, are included:

  • Podcast
  • Episode
  • Genre
  • GenrePodcast

Relationship types included:

  • belongsTo
  • hasMany
  • belongsToMany
Generates the following files:

controllers and controller tests discussed below

- database/factories/PodcastFactory.php
- database/factories/EpisodeFactory.php
- database/factories/GenreFactory.php
- database/factories/GenrePodcastFactory.php
- database/migrations/<timestamp>_create_podcasts_table.php
- database/migrations/<timestamp>_create_episodes_table.php
- database/migrations/<timestamp>_create_genres_table.php
- database/migrations/<timestamp>_create_genre_podcast_table.php
- app/Models/Podcast.php
- app/Models/Episode.php
- app/Models/Genre.php
- app/Models/GenrePodcast.php
- database/seeders/KickstartSeeder.php
- app/Http/Requests/PodcastStoreRequest.php
- app/Http/Requests/PodcastUpdateRequest.php
- app/Http/Requests/EpisodeStoreRequest.php
- app/Http/Requests/EpisodeUpdateRequest.php
- app/Http/Requests/GenreStoreRequest.php
- app/Http/Requests/GenreUpdateRequest.php
- app/Http/Resources/PodcastCollection.php
- app/Http/Resources/PodcastResource.php
- app/Http/Resources/EpisodeCollection.php
- app/Http/Resources/EpisodeResource.php
- app/Http/Resources/GenreCollection.php
- app/Http/Resources/GenreResource.php

Phone Book Template:

Example:

laravel new my-phone-book --kickstart=phone-book

This is the most advanced option, based on its more complex Eloquent relationships.

4 standard Eloquent models are included:

  • Person
  • Business
  • Phone
  • Address

Relationship types included:

  • belongsTo
  • onetoMany Polymorphic
  • manyToMany Polymorphic
Generates the following files:

controllers and controller tests discussed below

- database/factories/PersonFactory.php
- database/factories/BusinessFactory.php
- database/factories/PhoneFactory.php
- database/factories/AddressFactory.php
- database/migrations/2024_12_26_075242_create_people_table.php
- database/migrations/2024_12_26_075243_create_businesses_table.php
- database/migrations/2024_12_26_075244_create_phones_table.php
- database/migrations/2024_12_26_075245_create_addresses_table.php
- database/migrations/2024_12_26_075246_create_phoneables_table.php
- app/Models/Person.php
- app/Models/Business.php
- app/Models/Phone.php
- app/Models/Address.php
- database/seeders/PersonSeeder.php
- database/seeders/BusinessSeeder.php
- database/seeders/PhoneSeeder.php
- database/seeders/AddressSeeder.php
- app/Http/Requests/PersonStoreRequest.php
- app/Http/Requests/PersonUpdateRequest.php
- app/Http/Requests/BusinessStoreRequest.php
- app/Http/Requests/BusinessUpdateRequest.php
- app/Http/Requests/PhoneStoreRequest.php
- app/Http/Requests/PhoneUpdateRequest.php
- app/Http/Requests/AddressStoreRequest.php
- app/Http/Requests/AddressUpdateRequest.php
- app/Http/Resources/PersonCollection.php
- app/Http/Resources/PersonResource.php
- app/Http/Resources/BusinessCollection.php
- app/Http/Resources/BusinessResource.php
- app/Http/Resources/PhoneCollection.php
- app/Http/Resources/PhoneResource.php
- app/Http/Resources/AddressCollection.php
- app/Http/Resources/AddressResource.php

Controllers and Controller Tests Generation

The user will have the option to select which 'controller types' they'd like to generate.

Users can choose one of the following controller generation options:

  • Web Resource Controllers (for traditional web applications or the Blade stack)
  • API Resource Controllers (REST API focused applications)
  • No Controllers (Perfect for Livewire/Inertia.js applications)
  • Empty Controllers (For custom implementations)

When reaching this stage in the installation process, the most appropriate controller type will be selected (by default) based on the choices the user makes up to that point.

Implementation Notes

  • Follows existing coding style/type-hint conventions
  • Minimal core installer modification
  • Error handling that's consistent with how the installer already works
  • Controller/component code generation for Livewire and Inertia are coming to the laravel-shift/blueprint package soon. Once it is, I'll be planning to add them to this feature as well.

Cheers and Merry Xmas to everyone!

@jhavenz jhavenz force-pushed the 5.x-add-kickstart-option branch 5 times, most recently from c40e8e3 to afdc868 Compare December 26, 2024 19:09
@jhavenz
Copy link
Author

jhavenz commented Dec 26, 2024

I've applied formatting fixes where suggested.

The code relating to the failing CI/CD tests, I haven't messed with in this PR.

@jhavenz jhavenz force-pushed the 5.x-add-kickstart-option branch from afdc868 to 11804ca Compare December 26, 2024 19:14
@jhavenz jhavenz force-pushed the 5.x-add-kickstart-option branch from 11804ca to f889e84 Compare December 26, 2024 19:15
@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!

@jhavenz
Copy link
Author

jhavenz commented Dec 27, 2024

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!

Being that 6 of the 13 files changed in this PR are yaml, there's only 7 files with PHP logic in them, 2 of which are to keep the code organized (The NewCommand.php is already pretty large). That in mind, this PR packs a serious punch. I'm happy to accept any feedback.

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.

2 participants