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

🙋 How about php files? #262

Closed
Sigizmund2012 opened this issue Dec 14, 2017 · 17 comments
Closed

🙋 How about php files? #262

Sigizmund2012 opened this issue Dec 14, 2017 · 17 comments

Comments

@Sigizmund2012
Copy link

Just now I have project on my local server with php files( form handlers ). If I run Parcel on watch mode, php files not copying to dist folder and browser is not reload if I change those files.

🤔 Expected Behavior

I want from Parcel to reload browser( and index.php too ), when I change php files and copy them to dist folder.

😯 Current Behavior

The files not copying to dist folder, and browser not reloading, when I change php files.

@DeMoorJasper
Copy link
Member

Do you expect Parcel to just copy them over like they are html or really process and execute them as php?

@Sigizmund2012
Copy link
Author

Just copy like html and parse entry points of course :) I have my own local server, that executes php. But optional execution php may be the nice feature.

@chee
Copy link

chee commented Dec 15, 2017

this is just a matter of registering .php as an HTMLAsset, right?
the user can then parcel watch index.php and then serve their dist with their php server

@DeMoorJasper
Copy link
Member

It is if it’s about just html but if the point is decently supporting it than it’s bit more complex.

Sent with GitHawk

@chee
Copy link

chee commented Dec 15, 2017

absolutely, but what would decently supporting them be? a php dev server? that seems out of scope

@DeMoorJasper
Copy link
Member

DeMoorJasper commented Dec 15, 2017

Seems more like a plugin to me, thats why i labeled it help wanted

@chee
Copy link

chee commented Dec 15, 2017

I don't think a plugin is even needed, I can't think of any special bundling that could be performed for php that wouldn't be already performed by HTMLAsset. correct me if i'm wrong.

The only thing is the php would not execute on the current parcel index.php.

They can use parcel watch index.php and serve their dist/ with any php-enabled server, however, and still get the benefits of parcel.

Provided php is a registered HTML extension

@chee
Copy link

chee commented Dec 15, 2017

Oh, of course, other referenced php files wouldn't be copied without special treatment. i'm a fool

@DeMoorJasper
Copy link
Member

Feel free to test out your approach and do a PR @chee

@devanflaherty
Copy link

devanflaherty commented Dec 15, 2017

Hey there,
I'm sure I'm not completely getting this, but in my mind I'm thinking Parcel could be great for a simple wordpress build. I read through this thinking it might shed some light but still lost.

I can't seem to wrap my head around on how to get it to work in wordpress build, am I wrong in my thinking that this parcel could be a good solution in this instance?

@chee
Copy link

chee commented Dec 18, 2017

i have built a plugin that works with very, very simple php programs (ones that only ever include/require files with relative string paths, or dirname(__FILE__) + string paths) to get an idea of what's involved.
it works very well, but could not handle a real php application.
for a full php application, like a wordpress app, it would need quite a bit more work of ast walk work, translating to dependencies the various ways of including a file in php.

@devanflaherty which part of a wordpress build would you hope to use it for? what job would parcel be doing?

i haven't used a bundler along with a wordpress application, and i'm not sure where it fits in.

@ivanjuras
Copy link

I'd also like to know if it's possible to use Parcel with WordPress.

My use case is simple: I just want to split my scripts.js file into multiple files and bundle them together into a script that gets called in a wp_enqueue_script function.

I hate the fact that I have to use Webpack for that.

@chee
Copy link

chee commented Dec 21, 2017

@ivanjuras of course! you can use your scripts.js as your entry, so break your scripts.js up and then do parcel build scripts.js

@devongovett
Copy link
Member

Closing. If you want to add support for php somehow, feel free to write a plugin!

@jcklpe
Copy link

jcklpe commented Nov 21, 2018

@ivanjuras I imagine this is way old to reply to you, but just to let you know, you can use gulp for what you want to do with wordpress and it's way easier than webpack for that limited level of bundling needed. I actually skipped gulp to learn webpack because it's supposed to be the future, and it does work, but gulp handles php stuff much easier. If you like, I'd recommend this article on the subject: https://www.sitepoint.com/fast-gulp-wordpress-theme-development-workflow/

@hirasso
Copy link

hirasso commented May 15, 2020

I wrote a plugin for that:
https://www.npmjs.com/package/parcel-plugin-watch-reload

@krystyna93
Copy link

I wrote a plugin for that: https://www.npmjs.com/package/parcel-plugin-watch-reload

Thanks for this plugin, I was worried I couldn't use PHP with Parcel, so thanks a bunch!

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

No branches or pull requests

9 participants