PHP, Analytics and surroundings

Susan Sarandon
Release: 2024-11-21 08:07:14
Original
990 people have browsed it

PHP, Analytics and surroundings

Good morning everyone and happy MonDEV! ☕

Did you have a good weekend? Here the mood was set on day trips to the mountains, because taking your head off the monitor is a good thing, especially on the weekend! ?️

But as always, this is not an obstacle to bring you the tool of the week and start off great with some new discoveries.
This week we go back to see a very simple but very interesting tool for Laravel and go back, without much surprise by now, among Nuno Maduro's repos.

This week it's time for Pan PHP a still early-stage analytics tool but very interesting especially for its simplicity and ease of implementation.

This library, through a middleware, injects a JS library into your pages and allows you to observe (on the elements you choose) how many times they have been viewed/hovered over/clicked. The data is collected anonymously and sent in a grouped way to the server (to limit the requests sent), where they will be saved in a dedicated table.

The implementation requires very few steps:

Install the library with:

composer require panphp/pan
Copy after login

Then with artisan install pan:

php artisan install:pan
Copy after login

You will be asked to run the migration for the creation of the table: confirm and you will be ready to use it in your blade/html. How?
Simply by adding the attribute data-pan to the elements you want to monitor. For example, if you have a CTA and want to know how many users have viewed/clicked the button, this is a simple and fast way to do so.

For a quick view of the collected data you can use the command

php artisan pan
Copy after login

Then having the table pan_analytics available in the database you can manage this data in the way that you consider most appropriate ?

Articles of the week

  • Design Patterns PHP PHP week and more PHP! Not exactly an article but rather an entire repository that collects various design patterns with related examples, use cases, and implementations in PHP. For further doubts, for most of them, a link to the Wikipedia page describing the design pattern itself has been included.
  • Automate code commenting using VS Code and Ollama We always talk about writing code using AI, but we all know that it ends up in code that creates unexpected and unpredictable errors, and maybe we don't even remember writing it (because we actually didn't). But why not use AI to make the code written by us well documented? In the past, I talked about how to create an extension for VS Code. In this article, you will learn how to write an extension that uses Ollama to comment your code!

I would say that even this week we have loaded up on tools and readings! I hope you found something interesting, as always, any feedback is welcome!

Have a great start of the week!

Happy Coding! 0_1

The above is the detailed content of PHP, Analytics and surroundings. For more information, please follow other related articles on the PHP Chinese website!

source:dev.to
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template