talyssonoc / react-laravel

Package for using ReactJS with Laravel
895 stars 90 forks source link

Blade not rendering @react_component #25

Closed joshhornby closed 9 years ago

joshhornby commented 9 years ago

Hey,

This package looks great but I can't get it to work, I have followed the docs line for line but when it comes to including @react_component('Message', [ 'title' => 'Hello, World' ], [ 'prerender' => true ]) inside a blade file it just print it out as if its a string.

Is this a known fault or something I am doing incorrectly? Like I say I have followed the guide word for word.

Thanks

joshhornby commented 9 years ago

I have created an example repo which shows the issue

https://github.com/joshhornby/react-laravel-example

talyssonoc commented 9 years ago

Can you see in the logs if there's something about it ?

joshhornby commented 9 years ago

The logs are empty. Have you got a spare 5 mins to create an example working project? I can pull it down and compare with mine?

talyssonoc commented 9 years ago

Damn, it is really not rendering. Apparently it's not a error with react-laravel, I've tried to downgrade it in my test project and it keeps happening, I guess it's something with some update at Laravel framework, gonna check it soon and answer here, thanks !

joshhornby commented 9 years ago

Any update on this @talyssonoc?

talyssonoc commented 9 years ago

Not yet, @joshhornby :disappointed:, I've tried to open a issue about it (https://github.com/laravel/framework/issues/8990), but they don't seen to want to help too much...

I'm thinking about to create a version for Laravel 5.1, I guess this will work properly, do you have interest in it ? (But I'll still try to work with 5.0).

joshhornby commented 9 years ago

5.1 would be perfect for our dev team.

If you need any help I'd happily contribute just ping me! :+1:

talyssonoc commented 9 years ago

Gonna do it soon !

In case you're interested, I've developed a package that connects Phactory and Laravel (it's specially useful for Laravel 5.0, since Laravel 5.1 already has support for factories), you can check it here: https://github.com/talyssonoc/phactory-laravel

talyssonoc commented 9 years ago

Solved, @joshhornby !

joshhornby commented 9 years ago

Still isn't working for me, I am think this maybe a namespace clash with https://github.com/reactphp/promise. As you can see the whole ReactPHP project uses the React namespace.

talyssonoc commented 9 years ago

Damn, for me it's working fine (at least at Laravel 5.1). But I also think it could be because of ReactPHP. The error is the same ? The directive doesn't get rendered ? (Did you changed the version from 0.9 to 0.9.1 at your composer.json ?)

joshhornby commented 9 years ago

I have 0.9.1 in my composer. Are you using Homestead to serve your site? I have v8js installed on Homestead but not on my local mac only on my VM, do you think this may be causing the issues?

talyssonoc commented 9 years ago

Yes, I'm using Homestead, and v8js got to be installed just where the server is (i.e. Homestead), I don't think this may be the reason.

Can you check at your composer.lock if v0.9.1 was properly installed ? Also, can you check if the content of vendor/talyssonoc/react-laravel/lib/ReactServiceProvider.php is exactly like this file ?

joshhornby commented 9 years ago

I have updated my project which can be found here: https://github.com/joshhornby/react-laravel-example

The file was the same.

This project doesn't have the React namespace clash. Can you create a sample project and push up? If it works on your end and not mine then chances are my set up is incorrect.

talyssonoc commented 9 years ago

Sure I can ! Here it is: https://github.com/talyssonoc/react-laravel-example

joshhornby commented 9 years ago

Didn't work for me, must be something at my side then!

a-moses commented 9 years ago

@joshhornby maybe something with the last version of V8 ?

joshhornby commented 9 years ago

@a-moses Are you having the same issue? What version do you have installed on homestead @talyssonoc

talyssonoc commented 9 years ago

@joshhornby, I'm using Homestead 2.0.14

joshhornby commented 9 years ago

@talyssonoc Same here. I simply have just done

  $ sudo apt-get install libv8-dev g++
  $ sudo pecl install v8js-0.1.3

inside my homestead box. But when ever I load your example I just see the @react_component as a string.

talyssonoc commented 9 years ago

@joshhornby weird... I've tested it with v8js 0.1.3 and 0.2.0 (you can se how to install it here).

Try to delete your vendor folder and run composer update again.

joshhornby commented 9 years ago

I have added some logs into your service provider, and it seems the service provider is not getting picked up. Any reason why this might happen?

talyssonoc commented 9 years ago

I don't know exactly, it should be working, can you show me your composer.json ?

joshhornby commented 9 years ago
    "require": {
        "php": ">=5.5.9",
        "laravel/framework": "5.1.*",
        "talyssonoc/react-laravel": "0.9.1"
    },

And the lock file

{
            "name": "talyssonoc/react-laravel",
            "version": "v0.9.1",
            "source": {
                "type": "git",
                "url": "https://github.com/talyssonoc/react-laravel.git",
                "reference": "2e0f65a9630f917914d032cac2c1b4c437a869ae"
            },
            "dist": {
                "type": "zip",
                "url": "https://api.github.com/repos/talyssonoc/react-laravel/zipball/2e0f65a9630f917914d032cac2c1b4c437a869ae",
                "reference": "2e0f65a9630f917914d032cac2c1b4c437a869ae",
                "shasum": ""
            },
            "require": {
                "illuminate/support": "~5.0",
                "reactjs/react-php-v8js": "dev-master"
            },
            "require-dev": {
                "phpunit/phpunit": "~4.0.0@stable"
            },
            "type": "library",
            "autoload": {
                "classmap": [
                    "facades/"
                ],
                "psr-4": {
                    "React\\": "lib/"
                }
            },
            "notification-url": "https://packagist.org/downloads/",
            "license": [
                "MIT"
            ],
            "authors": [
                {
                    "name": "Talysson Oliveira",
                    "email": "talyssonoc@gmail.com"
                }
            ],
            "description": "Package to use ReactJS with Laravel",
            "keywords": [
                "laravel",
                "react",
                "reactjs"
            ],
            "time": "2015-06-11 13:00:14"
        },
talyssonoc commented 9 years ago

Well, that's weird... Did you registered the service provider on your config file ? Do it and then restart your php5-fpm service.

joshhornby commented 9 years ago

Yes, I am using the example you provided above. All I am seeing on screen is @react_component('Message', [ 'name' => 'Hue' ])

And the html looks like so

<html>
    <head>
        <script src="{{ asset('vendor/react-laravel/react.js') }}"></script>
        <script src="{{ asset('js/components.js') }}"></script>
        <script src="{{ asset('vendor/react-laravel/react_ujs.js') }}"></script>
    </head>
    <body>
        @react_component('Message', [ 'name' => 'Hue' ])
    </body>
</html>
talyssonoc commented 9 years ago

Damn, that's really weird, it should be working. @a-moses, that's what is happening to you too ?

joshhornby commented 9 years ago

http://laravel.com/docs/5.1/blade#extending-blade Have you seen this @talyssonoc

talyssonoc commented 9 years ago

I've seen, @joshhornby, but the Blade::directive doesn't exist at Laravel 5.0, I've tried to make it work with both 5.0 and 5.1 and in the Laravel repository I was told it would work.

joshhornby commented 9 years ago

Can you screen shot what you are seeing on your screen? Might also worth re opening this issue.

talyssonoc commented 9 years ago

Sure, @joshhornby, here it is:

react-laravel

I'm thinking about that, just wanna know if it is happening because of yours configs or a bug.

joshhornby commented 9 years ago

If you run composer update outside of your homestead ssh do you get an error?

talyssonoc commented 9 years ago

You mean, run composer update from the host machine ?

joshhornby commented 9 years ago

Yeh

talyssonoc commented 9 years ago

Nope, it runs correctly because I also have v8js in my host machine (but it is not necessary, but in this case I don't get a error because composer would check the dependencies like v8js in the host machine, if you run it from ssh it will check the dependencies inside homestead machine.

joshhornby commented 9 years ago

Not sure this is the case, I have the following error when running composer update outside on the VM:

Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - talyssonoc/react-laravel v0.9.1 requires reactjs/react-php-v8js dev-master -> satisfiable by reactjs/react-php-v8js[dev-master].
    - talyssonoc/react-laravel v0.9.1 requires reactjs/react-php-v8js dev-master -> satisfiable by reactjs/react-php-v8js[dev-master].
    - reactjs/react-php-v8js dev-master requires ext-v8js >=0.1.3 -> the requested PHP extension v8js is missing from your system.
    - reactjs/react-php-v8js dev-master requires ext-v8js >=0.1.3 -> the requested PHP extension v8js is missing from your system.
    - Installation request for talyssonoc/react-laravel 0.9.1 -> satisfiable by talyssonoc/react-laravel[v0.9.1].
talyssonoc commented 9 years ago

Yes, it's because of this, but it its bease your host machine doesn't have v8js, but it is not needed, you should run composer update from inside your homestead machine.

joshhornby commented 9 years ago

Yes that is what I thought, but was just checking because I can't think of a reason why this isn't working!

talyssonoc commented 9 years ago

Have you tried installing v8js in your physical machine and run your Laravel server from it, without using Homestead ?

a-moses commented 9 years ago

@talyssonoc I compiled V8 from the source and all work well as expected until make-test failed.

talyssonoc commented 9 years ago

It will happen depending on your machine, try to make install anyway and see if it works, @a-moses

a-moses commented 9 years ago

@talyssonoc of course i tried and v8 didn't work . we need to find the stable version for ubuntu homestead

18601673727 commented 9 years ago

v8js 0.2.1 is out and I tried with Laravel 5.1 and react-laravel 0.9.1 still not working...

18601673727 commented 9 years ago

I just tried {!! React::render('Message', [ 'name' => 'Hue' ], [ 'prerender' => true ]) !!} and it works!

talyssonoc commented 9 years ago

@joshhornby @a-moses @18601673727 Can you try this instructions here and say me if it does work? https://github.com/talyssonoc/react-laravel/issues/41#issuecomment-133704745