Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

zaster's avatar

How can i avoid doing the same things over and over

Some of the things i found out was

  1. Have your own set of packages
  2. Try https://github.com/nWidart/laravel-modules
  3. Try CRUD code generators etc...
  4. Try to write code in a way that you could use it over and over (Using inheritance etc...)
  5. What about copying and pasting code from your earlier projects ?
  6. What about having one big project with all what you know and kind of using it as a reference

What are your thoughts on these and what would be the pros and cons

0 likes
7 replies
bugsysha's avatar
  1. I avoid packages as much as possible if they are not well and regularly maintained by well known developers
  2. does not seem useful
  3. they are very useless
  4. inside one project yes, not to share between projects
  5. no
  6. no

I've wasted so many hours trying to come up with reusable and flexible enough approach which in the end becomes useless cause framework evolves and covers those shortcomings. Especially lately since Laravel adopted semver it feels like there is no need for packages. I just pay $9 to Laravel Shift for upgrade and rewrite some small parts to make code easier with new capabilities of the framework.

zaster's avatar

I think different developers have different experience / ideas

For example

1). What about developing your own set of packages to achieve kind of modular approach(not sure about this though) https://github.com/spatie

2). https://medium.com/@destinyajax/how-to-build-modular-applications-in-laravel-the-plug-n-play-approach-part-1-13a87f7de06

3). https://github.com/InfyOmLabs/laravel-generator CRUDs can be generated instantly and then you can customize according to your requirements

a model.json file is created. Something like this

[
    {
        "name": "id",
        "dbType": "increments",
        "htmlType": null,
        "validations": null,
        "searchable": false,
        "fillable": false,
        "primary": true,
        "inForm": false,
        "inIndex": false,
        "inView": false
    },
    {
        "name": "name",
        "dbType": "string",
        "htmlType": "text",
        "validations": "required",
        "searchable": true,
        "fillable": true,
        "primary": false,
        "inForm": true,
        "inIndex": true,
        "inView": true
    },
    {
        "name": "description",
        "dbType": "string",
        "htmlType": "textarea",
        "validations": "required",
        "searchable": true,
        "fillable": true,
        "primary": false,
        "inForm": true,
        "inIndex": true,
        "inView": true
    },
    {
        "name": "created_at",
        "dbType": "timestamp",
        "htmlType": null,
        "validations": null,
        "searchable": false,
        "fillable": false,
        "primary": false,
        "inForm": false,
        "inIndex": false,
        "inView": true
    },
    {
        "name": "updated_at",
        "dbType": "timestamp",
        "htmlType": null,
        "validations": null,
        "searchable": false,
        "fillable": false,
        "primary": false,
        "inForm": false,
        "inIndex": false,
        "inView": true
    }
]

5). Sometimes the views might look the same so you could copy the entire folder and do minor changes (create.blade.php, edit.blade.php, index.blade.php, show.blade.php etc...)

6). What about forking your project from a certain point where it seems like common stuff can be applicable for most of the similar kind of projects etc..

7). Considering the option to delay on updating you laravel project between versions. May be re-writing the entire application after 4 / 5 years (Since then most of the technologies have changed including the frontend (May be this approach raise security concerns , and mostly it can be due to third party plugins ?)

bugsysha's avatar
  1. Developing packages takes so much time which I do not have so that is not an option. And people tend to think that you have to develop that package forever and I do not want that kind of commitment.
  2. Like I said. Framework evolves and you get that feature out of the box and package becomes obsolete.
  3. Tried it and never used it again. Only one that I've used multiple times was Laravel Nova.
  4. I would rather create snippet for my editor than try to find it in some old project and copy it to new one and then try to find those small details which are different and can mess up your form or something and then I waste too much time on debugging it.
  5. Never had projects that are so similar that I can do that. That might work if you are rebranding something, but not for different products.
  6. If your app lives for 4-5 years it will be massive and rewriting it is a bad idea cause it will take you too much to do it and you'll loose to much specific use cases which build up over time. I think that only developers with less experience tend to rewrite the app.
artcore's avatar

I am writing (composer) packages for reuse always and deploy using a private repo. For me there's no other way to have the same features on multiple sites. Plus writing your own stuff helps experience ;)

zaster's avatar

@artcore thanks for the reply. I wonder what other ways are available.

I think may be writing your own artisan commands could be another option

Tray2's avatar
Tray2
Best Answer
Level 73

Like everything else it all depends.

However generators for view is in my opinion pretty clunky to us. I thnk it's much better to spend some time setting up good snippets to help with a lot of the tedious stuff.

The only generators I use are the ones supplied by Laravel to generate Controllers, Models, Factories, Migrations and so on.

zaster's avatar

Up to now , Custom made snippets seems like the way to go ahead

Please or to participate in this conversation.