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

cristo's avatar
Level 13

Is making changes to files inside the Spark directory OK?

Is making changes to files inside the Spark directory OK?

At the moment I just want to make some changes to Spark's views, routes and controllers. Should I simply overwrite them and put all my changes inside /app/ or can I make some changes to files in /spark?

What about resources/views/vendor/spark and all the Vue scripts?

0 likes
13 replies
EventFellows's avatar

@duellsy your answer is not correct, please update it.

Changes made in /vendor/ folder will be overwritten in next update (that'swhere all the spark source files are)

Only difference is for the spark view files that are exported to the application on installation into /recources/views/vendor/spark -> these can be changed as mentioned on spark docs and will not be overwritten

Hope that helps to avoid any trouble for people.

1 like
christian_H's avatar

So if we shouldn't modify the spark source files, what do you do if you need to modify the spark base code to fit your use cases? So far I've just been modifying anything I need to with the understanding that I won't easily be able to update my project, but is there a better way?

cristo's avatar
Level 13

I've been modifying the vendor files inside /resources because they're just views, but if I have to change something in the /spark directory, I've been just overwriting the route in the /app folder and creating new controllers.

EventFellows's avatar

There is a Spark::swap method that should serve almost all of these cases if you need to change something in Spark Code (that is at least what the documentation claims)

It is under customization in the docs and it did work as expected in the cases I have used it in so far. See here: https://spark.laravel.com/docs/1.0/customization

2 likes
cristo's avatar
Level 13

Would love a laracast on how to utilize that properly

martinbean's avatar

@cristo Never touch any files in your vendor or spark directories.

From the Spark documentation:

When you create a new application using spark new, all of the Spark views are automatically exported to your application's resources/views/vendor/spark directory. You may customize any of these views as needed.

1 like
cristo's avatar
Level 13

@martinbean I was referring to /resources/views/vendor/ but yes I understand now :-) thanks

cristo's avatar
Level 13

@EventFellows How can I use the Swap method to overwrite an event that's called by one of Spark's default controllers?

EventFellows's avatar

That depends on the method. It works for all methods that are called via Spark::interact()

What exactly do you want to do?

cristo's avatar
Level 13

Sorry nevermind. I just had not worked with events before and wasn't aware I could just add more listeners. Thanks though :)

envision's avatar

I'm starting a project that uses Spark as an API, ditching all views and Vue related things...building a custom Angular Single Page App that is hosted not in the public folder but in an another host.

I would like to document Spark's controller/routes and models with L5-Swagger but for that I would need to modify the core files for adding php annotations.

Apparently that is not an option. Perhaps there is another way to define Swagger annotations on routes files perhaps...

A feature suggestion for Spark: You perhaps could make /spark folder's source files editable and updatable like so that when update is run, check which files have been modified and either leave untouched and notify after the update OR try to merge those two file versions in the git manner...

Please or to participate in this conversation.