tighten / jigsaw

Simple static sites with Laravel’s Blade.
https://jigsaw.tighten.com
MIT License
2.13k stars 181 forks source link

Public_path() and other function collisions #284

Closed williambeeler closed 5 years ago

williambeeler commented 6 years ago

Hello Tightenco,

Just wanted to first say that I appreciate what you've done with Jigsaw and that I'm looking forward to showcasing what I've done with it!

So, when I install Laravel, and try to add-in Jigsaw to it, I get an error like the following:

PHP Fatal error: Cannot redeclare public_path() (previously declared in /path/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php:672) in /path/vendor/tightenco/jigsaw/src/Support/helpers.php on line 47

Fatal error: Cannot redeclare public_path() (previously declared in /path/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php:672) in /path/vendor/tightenco/jigsaw/src/Support/helpers.php on line 47

So, I went through and looked at the helpers.php file at line 47 and here's a sample of what I got:

if (! function_exists('public_path')) { ...

Well, isn't that function already declared? Why would this line be making noise if the function was already declared by Laravel?

It's a long story, but I'd like to use Jigsaw alongside a fresh installation of Laravel. I'm aware that may make some issues for you folks, but I think it's very useful for me.

Will

mattstauffer commented 6 years ago

Hey WIlliam!

This is happening because Jigsaw is not a package that you bring into Laravel; it's a static site generator that works through Markdown and PHP files and then spits out HTML, which you then upload to your host.

I can't fully imagine a workflow in which you would install Jigsaw as a dependency in a Laravel app; I hear you saying it's a long story and I get it. Is the issue that you want a single folder of your Laravel app to be generated HTML? Or is there something else you could explain relatively simply to us?

Thanks!

cossssmin commented 6 years ago

I can't fully imagine a workflow in which you would install Jigsaw as a dependency in a Laravel app;

Maizzle would be a candidate for that 😁

Haven't had the time to get on it, but I'll need to do just that. William, see this issue for some thoughts on the matter.

williambeeler commented 6 years ago

Hi @mattstauffer, and @hellocosmin,

Thank you for your replies. Btw, I'm really humbled to have you reply to my post, Matt. I've either used a lot of packages, and the like, from you, or I've read your blog a lot. And then there's the Laravel podcast of course. Wow.. Thank you.

As for the imagining a workflow. I guess it's not a long story, it was just something that I wasn't trying to focus on for the moment. I'm using Jigsaw to create a simple static site of Mapbox Maps, with JS and the like. However, to build out the Geojson, I have a large data set in an mysql database that changes each year. And I have to do stuff with the queries, so I have some models, etc. that I use. Well, I've tried to require individual packages on top of Jigsaw at one point, which didn't turn out that great. I felt like I was programming a new framework more than getting the job done. I didn't want to get away from the basic Laravel setup, so it became harder to accomplish what I wanted. Eventually, I just separated the concerns. I created an installation of Laravel to deal with the database and create and parse the Geojson and geometry, and then I had a separate installation for Jigsaw.

As for the error. What I was trying to say is that, according to the code that you created, there really shouldn't have been an error, correct? Because you were requiring that the public_path() function wasn't already loaded. So why the error, I guess I don't understand why I was even getting the error in the first place?

Thank you again!