How to fix “Non-static method SpatieAnalyticsAnalytics::fetchVisitorsAndPageViews() should not be called...












1















When i put:



use SpatieAnalyticsAnalytics;


It gives the error




'Non-static method should not be called statically'




But when I only put:



use Analytics;


I gives a white page on refresh or says




"The use statement with non-compound name 'Analytics' has no effect "




when starting.



I am using Laravel 5.5.4 and although it says the facade should be automatically setup, it wasn't working so I also added this manually to the // config/app.php:



'Analytics' => SpatieAnalyticsAnalyticsFacade::class,


But it still is not working.



from the package github. there was a solution



php artisan config:clear


but it did not work for me.










share|improve this question

























  • have you tried composer dump-autoload after the installation of Analytics?

    – MONSTEEEER
    Jan 3 at 9:41











  • yes. but same issue persists.

    – Ali Shaown
    Jan 3 at 10:46
















1















When i put:



use SpatieAnalyticsAnalytics;


It gives the error




'Non-static method should not be called statically'




But when I only put:



use Analytics;


I gives a white page on refresh or says




"The use statement with non-compound name 'Analytics' has no effect "




when starting.



I am using Laravel 5.5.4 and although it says the facade should be automatically setup, it wasn't working so I also added this manually to the // config/app.php:



'Analytics' => SpatieAnalyticsAnalyticsFacade::class,


But it still is not working.



from the package github. there was a solution



php artisan config:clear


but it did not work for me.










share|improve this question

























  • have you tried composer dump-autoload after the installation of Analytics?

    – MONSTEEEER
    Jan 3 at 9:41











  • yes. but same issue persists.

    – Ali Shaown
    Jan 3 at 10:46














1












1








1








When i put:



use SpatieAnalyticsAnalytics;


It gives the error




'Non-static method should not be called statically'




But when I only put:



use Analytics;


I gives a white page on refresh or says




"The use statement with non-compound name 'Analytics' has no effect "




when starting.



I am using Laravel 5.5.4 and although it says the facade should be automatically setup, it wasn't working so I also added this manually to the // config/app.php:



'Analytics' => SpatieAnalyticsAnalyticsFacade::class,


But it still is not working.



from the package github. there was a solution



php artisan config:clear


but it did not work for me.










share|improve this question
















When i put:



use SpatieAnalyticsAnalytics;


It gives the error




'Non-static method should not be called statically'




But when I only put:



use Analytics;


I gives a white page on refresh or says




"The use statement with non-compound name 'Analytics' has no effect "




when starting.



I am using Laravel 5.5.4 and although it says the facade should be automatically setup, it wasn't working so I also added this manually to the // config/app.php:



'Analytics' => SpatieAnalyticsAnalyticsFacade::class,


But it still is not working.



from the package github. there was a solution



php artisan config:clear


but it did not work for me.







laravel google-analytics laravel-5.5






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 3 at 9:38









Tufan Barış Yıldırım

3,5122234




3,5122234










asked Jan 3 at 9:04









Ali ShaownAli Shaown

183




183













  • have you tried composer dump-autoload after the installation of Analytics?

    – MONSTEEEER
    Jan 3 at 9:41











  • yes. but same issue persists.

    – Ali Shaown
    Jan 3 at 10:46



















  • have you tried composer dump-autoload after the installation of Analytics?

    – MONSTEEEER
    Jan 3 at 9:41











  • yes. but same issue persists.

    – Ali Shaown
    Jan 3 at 10:46

















have you tried composer dump-autoload after the installation of Analytics?

– MONSTEEEER
Jan 3 at 9:41





have you tried composer dump-autoload after the installation of Analytics?

– MONSTEEEER
Jan 3 at 9:41













yes. but same issue persists.

– Ali Shaown
Jan 3 at 10:46





yes. but same issue persists.

– Ali Shaown
Jan 3 at 10:46












2 Answers
2






active

oldest

votes


















0














It depends in what context you place the use statement.



In Laravel you also can use facades without having to import it with use.
The same class can be called by using Analytics in your code call.



Example:



Analytics::fetchMostVisitedPages(Period::days(7));






share|improve this answer































    0














    This package can be installed through Composer.



    composer require spatie/laravel-analytics



    In Laravel 5.5 and above the package will autoregister the service provider. In Laravel 5.4 you must install this service provider.



    config/app.php



    'providers' => [
    ...
    SpatieAnalyticsAnalyticsServiceProvider::class,
    ...
    ];


    In Laravel 5.5 and above the package will autoregister the facade. In Laravel 5.4 you must install the facade manually.



    config/app.php



    'aliases' => [
    ...
    'Analytics' => SpatieAnalyticsAnalyticsFacade::class,
    ...
    ];




    You want to use the facade to access the class, you will need to change:



    use SpatieAnalyticsAnalytics; to use Analytics;






    share|improve this answer


























    • i did all these things. unfortunately my problem still persists.

      – Ali Shaown
      Jan 3 at 10:47











    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54019125%2fhow-to-fix-non-static-method-spatie-analytics-analyticsfetchvisitorsandpagevi%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    It depends in what context you place the use statement.



    In Laravel you also can use facades without having to import it with use.
    The same class can be called by using Analytics in your code call.



    Example:



    Analytics::fetchMostVisitedPages(Period::days(7));






    share|improve this answer




























      0














      It depends in what context you place the use statement.



      In Laravel you also can use facades without having to import it with use.
      The same class can be called by using Analytics in your code call.



      Example:



      Analytics::fetchMostVisitedPages(Period::days(7));






      share|improve this answer


























        0












        0








        0







        It depends in what context you place the use statement.



        In Laravel you also can use facades without having to import it with use.
        The same class can be called by using Analytics in your code call.



        Example:



        Analytics::fetchMostVisitedPages(Period::days(7));






        share|improve this answer













        It depends in what context you place the use statement.



        In Laravel you also can use facades without having to import it with use.
        The same class can be called by using Analytics in your code call.



        Example:



        Analytics::fetchMostVisitedPages(Period::days(7));







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 3 at 11:17









        user3601546user3601546

        71110




        71110

























            0














            This package can be installed through Composer.



            composer require spatie/laravel-analytics



            In Laravel 5.5 and above the package will autoregister the service provider. In Laravel 5.4 you must install this service provider.



            config/app.php



            'providers' => [
            ...
            SpatieAnalyticsAnalyticsServiceProvider::class,
            ...
            ];


            In Laravel 5.5 and above the package will autoregister the facade. In Laravel 5.4 you must install the facade manually.



            config/app.php



            'aliases' => [
            ...
            'Analytics' => SpatieAnalyticsAnalyticsFacade::class,
            ...
            ];




            You want to use the facade to access the class, you will need to change:



            use SpatieAnalyticsAnalytics; to use Analytics;






            share|improve this answer


























            • i did all these things. unfortunately my problem still persists.

              – Ali Shaown
              Jan 3 at 10:47
















            0














            This package can be installed through Composer.



            composer require spatie/laravel-analytics



            In Laravel 5.5 and above the package will autoregister the service provider. In Laravel 5.4 you must install this service provider.



            config/app.php



            'providers' => [
            ...
            SpatieAnalyticsAnalyticsServiceProvider::class,
            ...
            ];


            In Laravel 5.5 and above the package will autoregister the facade. In Laravel 5.4 you must install the facade manually.



            config/app.php



            'aliases' => [
            ...
            'Analytics' => SpatieAnalyticsAnalyticsFacade::class,
            ...
            ];




            You want to use the facade to access the class, you will need to change:



            use SpatieAnalyticsAnalytics; to use Analytics;






            share|improve this answer


























            • i did all these things. unfortunately my problem still persists.

              – Ali Shaown
              Jan 3 at 10:47














            0












            0








            0







            This package can be installed through Composer.



            composer require spatie/laravel-analytics



            In Laravel 5.5 and above the package will autoregister the service provider. In Laravel 5.4 you must install this service provider.



            config/app.php



            'providers' => [
            ...
            SpatieAnalyticsAnalyticsServiceProvider::class,
            ...
            ];


            In Laravel 5.5 and above the package will autoregister the facade. In Laravel 5.4 you must install the facade manually.



            config/app.php



            'aliases' => [
            ...
            'Analytics' => SpatieAnalyticsAnalyticsFacade::class,
            ...
            ];




            You want to use the facade to access the class, you will need to change:



            use SpatieAnalyticsAnalytics; to use Analytics;






            share|improve this answer















            This package can be installed through Composer.



            composer require spatie/laravel-analytics



            In Laravel 5.5 and above the package will autoregister the service provider. In Laravel 5.4 you must install this service provider.



            config/app.php



            'providers' => [
            ...
            SpatieAnalyticsAnalyticsServiceProvider::class,
            ...
            ];


            In Laravel 5.5 and above the package will autoregister the facade. In Laravel 5.4 you must install the facade manually.



            config/app.php



            'aliases' => [
            ...
            'Analytics' => SpatieAnalyticsAnalyticsFacade::class,
            ...
            ];




            You want to use the facade to access the class, you will need to change:



            use SpatieAnalyticsAnalytics; to use Analytics;







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Jan 7 at 4:28

























            answered Jan 3 at 9:45









            Udhav SarvaiyaUdhav Sarvaiya

            2,43882131




            2,43882131













            • i did all these things. unfortunately my problem still persists.

              – Ali Shaown
              Jan 3 at 10:47



















            • i did all these things. unfortunately my problem still persists.

              – Ali Shaown
              Jan 3 at 10:47

















            i did all these things. unfortunately my problem still persists.

            – Ali Shaown
            Jan 3 at 10:47





            i did all these things. unfortunately my problem still persists.

            – Ali Shaown
            Jan 3 at 10:47


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54019125%2fhow-to-fix-non-static-method-spatie-analytics-analyticsfetchvisitorsandpagevi%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Mossoró

            Error while reading .h5 file using the rhdf5 package in R

            Pushsharp Apns notification error: 'InvalidToken'