davestewart / laravel-sketchpad

An innovative front-end environment for interactive Laravel development
MIT License
296 stars 19 forks source link

After Install Sketchpad setup displays nothing #2

Closed jimmck closed 7 years ago

jimmck commented 7 years ago

Laravel 5.4 PHP 7.1

Added via composer. Added service provider entry.

When I use sketchpad url, if returns a screen with Title Sketchpad and nothing else.

The URL is rewritten to sketchpad/setup

davestewart commented 7 years ago

Yaa boo, that's not good.

Thanks for posting. Let me set up a Homestead box and check that out :)

Any JS console errors?

jimmck commented 7 years ago

Hi, Good question. Here is the log.

Failed to load resource: the server responded with a status of 404 (Not Found) lib.js:1 Uncaught SyntaxError: Invalid or unexpected token components.css Failed to load resource: the server responded with a status of 404 (Not Found) setup:1 Failed to decode downloaded font: http://cvg.dev/sketchpad/assets/fonts/lato/lato-bold-webfont.woff setup:1 OTS parsing error: invalid version tag setup:1 Failed to decode downloaded font: http://cvg.dev/sketchpad/assets/fonts/lato/lato-bold-webfont.woff setup:1 OTS parsing error: invalid version tag setup.js:1 Uncaught SyntaxError: Invalid or unexpected token setup:1 Failed to decode downloaded font: http://cvg.dev/sketchpad/assets/fonts/lato/lato-bold-webfont.woff setup:1 OTS parsing error: invalid version tag components.css Failed to load resource: the server responded with a status of 404 (Not Found)

davestewart commented 7 years ago

Hmm. Weird.

My /sketchpad/setup on PHP7/Laravel5.4 runs just fine, but I'm getting problems post-installation that I think is composer not adding the new sketchpad namespace (not sure why, and unrelated to yours).

jimmck commented 7 years ago

Hi The dump was from console. It's a totally new 5.4 install. I did notice no folders where setup. Where is lib.js sourced from? Run Mac Sierra latest updates. Php7.1 install from Homebrew same for MySQL. I am running latest node 7 but if your not using global should be cool. I will dig in a bit more. Jim

On Apr 2, 2017, at 9:54 PM, Dave Stewart notifications@github.com wrote:

Hmm. Weird.

The lib.js should be fine, not sure why not, and is probably the culprit. Is there any more detail to that one? the component.css is an oversight on my behalf, now removed the font files not loading is strange; it should just load. Are you on Linux? What happens if you open that URL in a new tab? My /sketchpad/setup on the PHP7/Laravel5.4 runs just fine, but Im getting problems post-installation that I think is composer not adding the new sketchpad namespace (not sure why).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

davestewart commented 7 years ago

All the assets are loaded via a route and Symfony's BinaryFileResponse directly from davestewart/sketchpad/src/publish/assets. Makes it much easier to develop without having to copy to public each time I make a change!

Can you SHIFT+CMD+4 (copy) your console output then paste here?

davestewart commented 7 years ago

OK. Solved my composer issues; I need to add a composer dumpautoload to the install (run that manually if you get things running and you get a failed step in the final stage)

Any more info regarding your install, I'll pick up tomorrow.

Thanks for the feedback!

jimmck commented 7 years ago

I posted the console output up on the Git issues page

On Apr 2, 2017, at 10:17 PM, Dave Stewart notifications@github.com wrote:

All the assets are loaded via a route and Symfony's BinaryFileResponse directly from davestewart/sketchpad/src/publish/assets. Makes it much easier to develop without having to copy to public each time I make a change!

Can you SHIFT+CMD+4 (copy) your console output then paste here?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

davestewart commented 7 years ago

Yup, but I'd like to see the screenshot if you can manage that?

jimmck commented 7 years ago

Here Ya Go!

On Sun, Apr 2, 2017 at 10:17 PM, Dave Stewart notifications@github.com wrote:

All the assets are loaded via a route and Symfony's BinaryFileResponse directly from davestewart/sketchpad/src/publish/assets. Makes it much easier to develop without having to copy to public each time I make a change!

Can you SHIFT+CMD+4 (copy) your console output then paste here?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/davestewart/laravel-sketchpad/issues/2#issuecomment-291034978, or mute the thread https://github.com/notifications/unsubscribe-auth/ACNyu1rFKggt93PpxsnxduVkGguIY4FJks5rsFamgaJpZM4Mw7_T .

davestewart commented 7 years ago

Ah - sorry - it didn't work by email!

Just paste it into the comment section live on the thread :) https://github.com/davestewart/laravel-sketchpad/issues/2

jimmck commented 7 years ago
screen shot 2017-04-02 at 11 15 07 pm

Image

davestewart commented 7 years ago

Brilliant, thanks. Now click on the "lib.js:1" link, then the "Pretty print" code button so I can see what's going on, like this:

image

jimmck commented 7 years ago

Dave, There is no pretty print icon for the JS sources? If you look at the error, there is a unprintable character at the start of line 1 before the comment.

/*! jQuery v1.12.3 | (c) jQuery Foundation | jquery.org/license */
!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=
jimmck commented 7 years ago

This is odd as during the course install Laravel54, before I fixed the access permissions for the cache directories you get a little 'square' character on a otherwise blank screen.

Is something polluting your input stream?

davestewart commented 7 years ago

That's really odd, and certainly something outside of my experience.

This is the file it's being pulled from:

This is the code which is pulling it:

I wonder if it's a encoding flag on the Symfony class?

Do you want to have a play with that in your install?

FYI. the pretty print button is the {} on the bottom left of the debug tools sources window

jimmck commented 7 years ago

Here check out the main Laravel Welcome page, look upper left corner...

screen shot 2017-04-03 at 9 26 42 am
davestewart commented 7 years ago

Can you try adding an encoding type to the getAsset() method?

$response->setCharset('UTF-8');
davestewart commented 7 years ago

Or maybe this is a BOM issue? Would make sense as it's the first character in the file.

http://stackoverflow.com/questions/2558172/utf-8-bom-signature-in-php-files

jimmck commented 7 years ago

Hey, So we are dealing with a fresh 5.4 install and I changed the welcome blade to my own welcome1 blade that does nothing!!!

<!DOCTYPE html>

Title

And the nonsense character appears.

Setting through Blade processing now.

Now I am hooked as rely on Blade and JS all the time. First time playing with 5.4

And your middleware use is very interesting to me...

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

davestewart commented 7 years ago

Maybe get on laracasts and see if you can figure that out, then let me know?

davestewart commented 7 years ago

Regarding the font issue, it looks like only the bold Lato font is having issues.

Can you swap out this version (to vendor/davestewart/sketchpad/publish/assets/fonts/lato) and see if you still get errors?

lato-bold.woff.zip

jimmck commented 7 years ago

Its not in Blade generator. The junk is coming from before. Not getting this is Zend. Laravel autoload.php is fine. Do you see this on 5.4 on any of your machines?

davestewart commented 7 years ago

No, all renders just fine for me.

I'm running Homestead 2 and the Laravel CLI, so laravel new projectname

What happens if you return a simple string from a controller, like 'hello world' ?

jimmck commented 7 years ago

Its somewhere in the code called from index.php. My own .php files are fine.

davestewart commented 7 years ago

I guess perhaps there's a rogue file somewhere in the bootstrap that is outputting this

If you remove the SketchpadServiceProvider, and go to index.php do you still see it?

Also, if you open one of the CSS files in new tab, do you see the  characters?

jimmck commented 7 years ago

Nope. Comment out your stuff and its the same. This is happening somewhere before the actual content is being created. When I look at the content variable before Laravel echo's it out it has just my minimal HTML file file rendered from the Blade. The content is getting polluted, but where? If I comment out all the Laravel bootstrapping and loading and echo Test, is fine. I have never seen this before. This junk is fouling up anything.

davestewart commented 7 years ago

Yeah, that sucks.

OK, it sounds like this is not a Sketchpd issue then. Happy for me to close this?

PS. Did you get a chance to try that alternative font file?

jimmck commented 7 years ago

Hey, Well here is whats up. Something is going with laravel. Consider this index.php file.

<?php
/**
 * Created by PhpStorm.
 * User: jimm
 * Date: 4/3/17
 * Time: 10:59 AM
 */
require __DIR__ . '/../bootstrap/autoload.php';
$app = require_once __DIR__ . '/../bootstrap/app.php';

//echo "Testing";
$out1 = ob_get_contents();
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
$out1 = ob_get_contents();
$response = $kernel->handle($request = Illuminate\Http\Request::capture());
$out1 = ob_get_contents();
ob_clean();
$response->send();
$out1 = ob_get_contents();
$kernel->terminate($request, $response);

I have added code to get the contents of the output at various points and examine it at breakpoints in PHPStorm.

After the $kernel->handle call the buffer has garbage character. If go and clean up the buffer before calling send() the output of the standard Laravel welcome blade displays as expected without odd character.

But when I run sketchpad URL the lib.js library still fails on line one with a bad token error right before the comment.

Have you actually run this against 5.4. I ran an update and got a new one 5.4.17. And the garbage character is still there.

But even when I clean the buffer lib.js is failing.

jimmck commented 7 years ago

After editing lib.js to remvove line 1 and clearing browser cache, sketchpad loads.

davestewart commented 7 years ago

Hey, well done for sticking with it! I hope it was worth it :P

So did you determine the problem was Sketchpad or Laravel?

jimmck commented 7 years ago

The lib.js that is installed in the ../assets/js folder of your package has a bad character at the start of the file. If you edit the file and remove the first line, sketchpad loads. The laravel funny character issue is separate. So something up with packagist image?

davestewart commented 7 years ago

Hmm, it is weird. I have a test install which loads and installs from packagist just fine.

I'm releasing another update tonight, so maybe you can try that.

jimmck commented 7 years ago

Let me know when you do please. On the garbage character front, it happens when Laravel generates events for the web page. One of the bootstrappers has a memory leak or is dumping into the PHP output buffer.

davestewart commented 7 years ago

OK, updated. See install notes: https://github.com/davestewart/laravel-sketchpad/wiki/Installation

jimmck commented 7 years ago

Hi, Thanks I will give it a go. I found something interesting. I had a bad character before the <php in app.php and during bootstrap it gets dropped into the output stream. That may have made your JS file look corrupt once it got cached. Figuring out how to write this up because the bootstrap array gets built properly because the PHP include only cares about what's after the opening tag.

Jim

On Apr 3, 2017, at 6:48 PM, Dave Stewart notifications@github.com wrote:

OK, updated. See install notes: https://github.com/davestewart/laravel-sketchpad/wiki/Installation

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

davestewart commented 7 years ago

Yep, that would make sense as the assets are being loaded via index.php.

No bother, running a 5.4 install helped me catch a couple of other bugs anyway, so it was worthwhile!

If you have any further feedback, don't hesitate to raise an issue, or comment in the laracasts thread

Cheers, Dave

jimmck commented 7 years ago

FYI I can confirm invalid character(s) before the <php tag in app.php get dumped into PHP output stream. If you clear the cache and reload sketchpad it gets pretended to lib.js which gives an error to sketchpad. So middleware and other cached items seem vulnerable.

On Apr 3, 2017, at 7:15 PM, Dave Stewart notifications@github.com wrote:

Closed #2.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.