Menu icon Foundation
Use foundation with PHP files.

Is't possible to change from .html files to .php files in Foundation 6, or any other way to use PHP.

PHP

Is't possible to change from .html files to .php files in Foundation 6, or any other way to use PHP.

Rafi Benkual almost 4 years ago

I don't see why not? WordPress is a php file system and it works with Foundation as does Laravel.

Here is a Larvel starter template that might give you some hints: https://github.com/gpspake/laravation

Brian Tan almost 4 years ago

With F6-sites basic template, no problem as long as your server support php.

If you are using f6-sites zurb advanced template, you'll have to update gulpfile.js to include php extension for the php files to be flattened and copied to dist/

Browser-sync (ie. localhost:8000) does not support php in server mode. You'll need php capable server (nginx/httpd + php-fpm or xampp), and run browser-sync in proxy mode, I think.

Jonas almost 4 years ago

Easier then i thinked. Only one line change in gulpfile.js.

Another question can i put own css files somewhere?

Brian Tan almost 4 years ago

If you want to generate multiple css file via sass, change sass task gulp.src from app.scss to *.scss

 gulp.task('sass', function() {
...
  return gulp.src('src/assets/scss/*.scss')
...

If you have your own css from else where, just add it in your layouts/default.html

P/S: I added extra exclude to PATHs.assets as foundation watch bombs out on php edit (vim save)

 var PATHS = {
  assets: [
    'src/assets/**/*',
    '!src/assets/{img,js,scss}/**/*',
    '!src/assets/php/*.php~'

Jonas almost 4 years ago

How can i change the browser-sync to proxy mode?

Brian Tan almost 4 years ago

change server to proxy and specify your vhost name. optional port to access from browser (default 3000)

 // Start a server with LiveReload to preview the site in
gulp.task('server', ['build'], function() {
  browser.init({
//    server: 'dist', port: PORT
    proxy: "http://www.yourdomain.com", port: 3000
  });
});

Rafi Benkual almost 4 years ago

@Brian Tan Sounds like you have some helpful experience with this!

@Jonas Make sure to hit "helpful" when someone helps you ;)

Brian Tan almost 4 years ago

Yes @Rafi Benkual , I'm migrating some php websites from basic to zurb template. Learn along the way. I ran nginx with php-fpm, but I believe the proxy setup should work with apache / php-fpm too.

Jonas almost 4 years ago

Cannot get this to work. Have hard time to get the php to run locally. But keep trying.

Brian Tan almost 4 years ago

Are you not able to get php to run in nginx/apache + php-fpm natively?

Jonas almost 4 years ago

I can't find a way to connect wamp with my foundaton files.

Brian Tan almost 4 years ago

If WAMP is serving on localhost, try specify http://localhost in proxy line

 // Start a server with LiveReload to preview the site in
gulp.task('server', ['build'], function() {
  browser.init({
//    server: 'dist', port: PORT
    proxy: "http://localhost", port: 3000
  });
});

Jonas almost 4 years ago

When i do that i'm being directed to Wampserver homepage - Server configuration.

Do i need to change wampservers www folder? And i how do i do that?

Brian Tan almost 4 years ago

What URLs do you use to access wamp directly? Put that URL in proxy line.

Jonas almost 4 years ago

It is http://localhost, but as i said, instead of my index i'm being directed to wamp configuration.

Brian Tan almost 4 years ago

I'm sorry, I'm not familiar with wamp. Could be wamp configuration problem. But if you put this URLs in your browser after starting foundation watch, http://localhost:3000/index.php, do you get home page?

Yuri Refolo almost 4 years ago

Hi Brian, my problem is that I don't know how to update gulpfile.js to include php files and also I don't know where to put .php files... can you help me?

Brian Tan almost 4 years ago

@Yuri Refolo Please see your main thread for gulpfile.js update.

src/pages/ files are flattened and copied to dist/ so xxx.php in src/pages is accessed via URL http://domain.com/xxx.php. xxx.php can have panini handle bar includes from src/partials folder

src/assets/php/ files are copied as is to dist/assets/php/ so 'login.php' in src/assets/php is accessed via URL "/assets/php/login.php", useful for Ajax calls.

Yuri Refolo almost 4 years ago

Many thanx, I've seen and replied... it works like a charm! Thank you again.

Rafi Benkual almost 4 years ago

Just saw that Foundationize was released. It's Foundation 6 and PHP, worth a look!