Giter Club home page Giter Club logo

Comments (25)

albertcht avatar albertcht commented on May 20, 2024 1

Ok, here is the problem:

public function __construct() {
    $this->page = request('page', 1)
}

Since each controller class will be resolved only in the first time. So you can't set page in the constructor. You have to get it in each separate function.

There's one important concept: Your laravel application is stored in memory after you use this package. So you have to reset or recycle those variables by yourself. In traditional PHP-FPM, all your resource will be destroyed after request process is done. Developers don't need to care about if their class or variable effects the next request. Now it matters.

from laravel-swoole.

deepaksp avatar deepaksp commented on May 20, 2024 1

ok cool .. thanks 👍

from laravel-swoole.

albertcht avatar albertcht commented on May 20, 2024 1

Hi @deepaksp ,

In the release v2.3.7 pagination issue should be fixed. You can go check it.

And I don't quite understand about your log issues. Can you provide more detail about that?

from laravel-swoole.

albertcht avatar albertcht commented on May 20, 2024

Please provide more detail about your question, thanks.

from laravel-swoole.

deepaksp avatar deepaksp commented on May 20, 2024

The paging query is not working
Check
https://celebpix.net/scarlett-johansson-disney-and-marvels-avengers-infinity-war-premiere-in-los-angeles-ca-04232018-45.html?page=1

https://celebpix.net/scarlett-johansson-disney-and-marvels-avengers-infinity-war-premiere-in-los-angeles-ca-04232018-45.html?page=2

Both pages showing same content

from laravel-swoole.

albertcht avatar albertcht commented on May 20, 2024

Hi @deepaksp ,

Can you please read Issues Guideline and then try to describe your issue more specifically?

Otherwise I have no clues how I can help you, thanks.

from laravel-swoole.

deepaksp avatar deepaksp commented on May 20, 2024

ok few things i solved the issue
1 . i was setting request variable in controller construct and that seems to create problem.
eg.

public function __construct() {
    $this->page = request('page', 1)
}

output of $this->page was always 1

  1. i think nginx config needs 1 change (at-least for me this change worked)
    i was not getting request data in home pages

     if ($uri = /index.php) {
         set $suffix "/?$args"; # added $args for request ??
     }
    

let me know what you think about nginx config !

from laravel-swoole.

deepaksp avatar deepaksp commented on May 20, 2024

yes i understand now, little new for me.
what about nginx config ?

from laravel-swoole.

albertcht avatar albertcht commented on May 20, 2024

Well, I think you don't need to make that change on Nginx config. If you get page parameter in each function, you should be able to see the correct result.

from laravel-swoole.

deepaksp avatar deepaksp commented on May 20, 2024

no its not working without that change.

from laravel-swoole.

albertcht avatar albertcht commented on May 20, 2024

What's your access url? Actually you can ignore that part because unless you access your app with url: http://yourweb.site/index.php or that section will not take effect.

from laravel-swoole.

deepaksp avatar deepaksp commented on May 20, 2024

https://celebpix.net/

I didn't meant website not working only i cant get request('page') for pages which has pagination interestingly search was working fine (i was able to get request('q') for search page ).

if you want i can updated nginx to old conf.

from laravel-swoole.

albertcht avatar albertcht commented on May 20, 2024

I've tested on my side with the same Nginx config, and it works properly.

Maybe you can try to dump request()->all() first to check if you can get all the query parameters.

from laravel-swoole.

deepaksp avatar deepaksp commented on May 20, 2024

old-conf

nope not working..
one more thing i am using docker !

from laravel-swoole.

albertcht avatar albertcht commented on May 20, 2024

Ok, I think we can make things simpler. Does it work if it's not behind Nginx proxy? If it only happens behind Nginx, you can paste your Nginx config for reference.

from laravel-swoole.

deepaksp avatar deepaksp commented on May 20, 2024

Yes its work when not in nginx proxy

from laravel-swoole.

deepaksp avatar deepaksp commented on May 20, 2024

one more thing can you add how to run in background notes.
i am using supervisor but its not able to stop gracefully .. here is my conf for supervisor

[program:laravel-swoole]
process_name=%(program_name)s_%(process_num)02d
command=docker exec php php /path/to/artisan swoole:http start
autostart=true
autorestart=true
user=root
stopsignal=KILL
killasgroup=true
redirect_stderr=true
stdout_logfile=/var/logs/worker.log

from laravel-swoole.

albertcht avatar albertcht commented on May 20, 2024

Hi @deepaksp ,

So can you provide your Nginx config for reference?

And in fact you can run swoole server in daemon mode by setting your .env

SWOOLE_HTTP_DAEMONIZE=true

from laravel-swoole.

deepaksp avatar deepaksp commented on May 20, 2024

oh yes i found that to

here is my nginx config file ..

`
server {
listen 80;
index index.php index.html;

server_name example.com;

root /data/code/example.com/public;


keepalive_timeout 10;

location = /index.php {
     try_files /not_exists @swoole;
}

location / {
    try_files $uri $uri/ @swoole;
}


location ~ \.php$ {
    try_files $uri =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass php;
    fastcgi_index index.php;
    fastcgi_keep_conn on;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include /etc/nginx/fastcgi_params;
}

location @swoole {
    set $suffix "";

    if ($uri = /index.php) {
        #set $suffix "/";
        set $suffix "/?$args";
    }
    proxy_set_header Connection "keep-alive";
    proxy_set_header Host $host;
    proxy_set_header SERVER_PORT $server_port;
    proxy_set_header REMOTE_ADDR $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Upgrade $http_upgrade;
    proxy_http_version 1.1;
    proxy_set_header Connection "";
    #proxy_set_header Connection $connection_upgrade; - was throuwing error so have to disable it
    # IF https
    # proxy_set_header HTTPS "on";
    proxy_pass http://127.0.0.1:1215$suffix;
}


error_log  /var/logs/error.log;
access_log /var/logs/access.log;

}

`

from laravel-swoole.

albertcht avatar albertcht commented on May 20, 2024

Hi @deepaksp ,

FYI, in the newest release, I've made it clean resolved controller on every request. You can check it with your previous code.

As for the Nginx config, because I'm working on other issues, I will leave it here for a while.

from laravel-swoole.

deepaksp avatar deepaksp commented on May 20, 2024

this issue started again in update

this time request is fine but every page showing page 1 data.

eg.

for - ?page=1
Post::paginate(10);

output - page 1 data

for - ?page=2
Post::paginate(10);

output - page 1 data

expected output - page 2 data

also there is log issue. it caches first error and displays same error every time there is some error even when it should not

from laravel-swoole.

lilianjin avatar lilianjin commented on May 20, 2024

Need help

map $http_upgrade $connection_upgrade {
    default upgrade;
    ''      close;
}

server {
    listen          80;
    server_name     demo.com;
    charset         utf-8;
    root            /sites/demo/public;

    gzip on;
    gzip_static on;
    gzip_http_version 1.0;
    gzip_disable "MSIE [1-6].";
    gzip_vary on;
    gzip_comp_level 9;
    gzip_proxied any;
    gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript image/svg+xml;

    fastcgi_intercept_errors off;
    fastcgi_buffers 8 16k;
    fastcgi_buffer_size 32k;
    fastcgi_read_timeout 180;

    # Remove trailing slashes
    rewrite ^/(.*)/$ /$1 permanent;

    access_log  /sites/demo/storage/logs/default.access.log;

    location = /index.php {
        # Ensure that there is no such file named "not_exists"
        # in your "public" directory.
        try_files /not_exists @swoole;
    }


    location / {
        try_files $uri $uri/ @swoole;
        #$try_files $uri $uri/ /index.php?$args;
####$        index  index.php;
####$        autoindex   on;
####$        include  /usr/local/etc/nginx/php-fpm;
####$        add_header 'Access-Control-Allow-Origin' 'http://app.com';
####$        add_header 'Access-Control-Allow-Credentials' 'true';
####$        add_header 'Access-Control-Allow-Methods' 'GET, POST, PATCH, PUT, OPTIONS';
####$        add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,X-XSRF-TOKEN,X-CSRF-TOKEN,Origin';
    }

    location @swoole {
        set $suffix "";

        if ($uri = /index.php) {
            set $suffix "/?$args";
        }

        proxy_set_header Connection "keep-alive";
        proxy_set_header Host $host;
        proxy_set_header SERVER_PORT $server_port;
        proxy_set_header REMOTE_ADDR $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Upgrade $http_upgrade;
        proxy_http_version 1.1;
        proxy_set_header Connection "";
        #proxy_set_header Connection $connection_upgrade; - was throuwing error so have to disable it
        # IF https
        # proxy_set_header HTTPS "on";
        proxy_pass http://127.0.0.1:1215$suffix;
    }

    location ~ /\.ht {
        access_log off;
        log_not_found off;
        deny all;
    }

    location ~* \.ico$ {
        expires 1w;
        access_log off;
    }

    location ~* \.(?:jpg|jpeg|gif|png|ico|gz|svg|svgz|ttf|otf|woff|eot|mp4|ogg|ogv|webm)$ {
        try_files $uri $uri/ /index.php?$query_string;

        access_log off;
        log_not_found off;
    }

    location ~* \.(?:css|js)$ {
        try_files $uri $uri/ /index.php?$query_string;
        access_log off;
        log_not_found off;
    }

    client_max_body_size 512M;

    add_header "X-UA-Compatible" "IE=Edge,chrome=1";
}

from laravel-swoole.

albertcht avatar albertcht commented on May 20, 2024

Hi @deepaksp ,

Thanks for reporting pagination issues, this is caused by dirty app binding in PaginationServiceProvider:

Paginator::currentPageResolver(function ($pageName = 'page') {
            $page = $this->app['request']->input($pageName);

            if (filter_var($page, FILTER_VALIDATE_INT) !== false && (int) $page >= 1) {
                return (int) $page;
            }

            return 1;
        });
    }

I'm trying to fix it.

As for the log, can you fix that by adding log to instances in swoole_http.php?

from laravel-swoole.

albertcht avatar albertcht commented on May 20, 2024

Hi @olivia-outshine ,

Is your comment related to this issue topic? I just can't find any clues how I can help you. Please read Issues Guideline and open another issue for your question, thanks.

from laravel-swoole.

deepaksp avatar deepaksp commented on May 20, 2024

thanks @albertcht for working so hard but for now i have disabled in production, once you update i will test in local environment.

from laravel-swoole.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.