You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/connections/sources/catalog/libraries/server/php/index.md
+11-11Lines changed: 11 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,13 +6,13 @@ support_type: maintenance
6
6
---
7
7
Segment's PHP library lets you record analytics data from your PHP code. The requests hit Segment servers, and then Segment routes your data to any analytics service you enable on your destinations page.
8
8
9
-
This library is open-source, so you can [check it out on GitHub](https://github.com/segmentio/analytics-php).
9
+
This library is open-source, so you can [check it out on GitHub](https://github.com/segmentio/analytics-php){:target="_blank”}.
10
10
11
11
PHP is a little different than Segment's other server-side libraries because it is a single-threaded language. Segment worked to make the PHP library as performant as possible, while still leaving you room to tune the settings for your application. If you want to learn more about tuning your settings for high performance, be sure to read through the section on [configuration](#configuration) at the end of this guide.
12
12
13
-
Want to stay updated on releases? Subscribe to the [release feed](https://github.com/segmentio/analytics-php/releases.atom).
13
+
Want to stay updated on releases? Subscribe to the [release feed](https://github.com/segmentio/analytics-php/releases.atom){:target="_blank”}.
14
14
15
-
## Getting Started
15
+
## Getting started
16
16
17
17
Clone the repository from GitHub into your desired application directory.
18
18
@@ -103,7 +103,7 @@ Find details on the **identify method payload** in the [Segment Spec](/docs/conn
103
103
104
104
Track lets you record the actions your users perform.Every action triggers what Segment calls an "event", which can also have associated properties.
105
105
106
-
You'll want to track events that are indicators of success for your site, like **Signed Up**, **Item Purchased** or **Article Bookmarked**.
106
+
You'll want to track events that are indicators of success for your site, like **Signed Up**, **Item Purchased**, or **Article Bookmarked**.
107
107
108
108
To get started, Segment recommends tracking just a few important events. You can always add more later.
109
109
@@ -318,7 +318,7 @@ Segment::track(array(
318
318
319
319
For more details about Alias including the **Alias call payload**, check out the [Segment Spec](/docs/connections/spec/alias/).
320
320
321
-
## Historical Import
321
+
## Historical import
322
322
323
323
You can import historical data by adding the `timestamp` argument to any of your method calls. This can be helpful if you've just switched to Segment.
The [lib-curl consumer](https://github.com/segmentio/analytics-php/blob/master/lib/Segment/Consumer/LibCurl.php) is a reliable option for low-volume sources or if you want fast response times under light loads. The library runs synchronously, queuing calls and sending them in batches to Segment's servers. By default, this happens every 100 calls, or at the end of serving the page. By default, Segment ignores http responses to optimize the library's speed, but you can choose to wait for these responses by enabling debug mode.
The [fork-curl consumer](https://github.com/segmentio/analytics-php/blob/master/lib/Segment/Consumer/ForkCurl.php) should work best for cases where you can't use persistent sockets, or want to ensure quick response times under light load. It works by creating an in-memory queue which buffers track and identify calls. The queue is flushed by forking an async `curl` process that sends a batch request. By default, this happens every `100` calls, or at the end of serving the page. This consumer will spawn a separate process for each request which tracks events. If your servers are handling more than 20 requests per second, you may want to look at the [file consumer](#file-consumer).
If you can't spawn other processes from your PHP scripts, you can use the [socket consumer](https://github.com/segmentio/analytics-php/blob/master/lib/Segment/Consumer/Socket.php), which will allow you to make requests to Segment. Each time a track or identify call is made, it will initiate a socket request to Segment's servers. The socket request is about as async as you can get with PHP, where the request will write the event data and close the connection before waiting for a response. However, if your servers are dealing with more than 100s of requests per second or cannot use a persistent connection, you may want to use one of the other consumers instead.
The [file consumer](https://github.com/segmentio/analytics-php/blob/master/lib/Segment/Consumer/File.php) is a more performant method for making requests to Segment. Each time a track or identify call is made, it will record that call to a log file. The log file is then uploaded "out of band" by running the `file.php` file found in [the analytics-php repository](https://github.com/segmentio/analytics-php/blob/master/lib/Segment/Consumer/File.php).
489
489
@@ -526,6 +526,6 @@ $ sudo service cron reload # reload the cron daemon
526
526
{% include content/server-side-troubleshooting.md %}
527
527
528
528
529
-
## 3rd-Party Libraries
529
+
## 3rd party libraries
530
530
531
-
Laravel Segment is a Segment SDK, for Laravel. The GitHub repo can be found here: [slashEquip/laravel-segment](https://github.com/slashequip/laravel-segment){:target="_blank”}.
531
+
Laravel Segment is a Segment SDK for Laravel. View the [slashEquip/laravel-segment](https://github.com/slashequip/laravel-segment){:target="_blank”} GitHub repo to learn more.
0 commit comments