Skip to content

Commit 653d8d4

Browse files
authored
Merge pull request #234 from planetteamspeak/fix/issue-223-composer-autoload
fix: update Composer installation examples
2 parents 4eb9917 + 3905577 commit 653d8d4

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

‎README.md‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Speed up new development and reduce maintenance costs by using this nifty piece
4141

4242
Note that the majority of TS3 PHP Framework development and deployment is done on nginx, so there is more community experience and testing performed on Apache than on other web servers.
4343

44-
You can install the TS3 PHP Framework by [manually downloading](https://github.com/planetteamspeak/ts3phpframework/archive/refs/heads/master.zip) it or using Composer.
44+
Install the TS3 PHP Framework with [Composer](https://getcomposer.org/). Composer generates the PSR-4 autoloader required by the framework.
4545

4646
Install the latest available release:
4747

@@ -187,7 +187,7 @@ Additional:
187187
* [RFC 2396 - Section 3](https://tools.ietf.org/html/rfc2396#section-3.4) - Valid URI syntax (specifically, components of)
188188
* [PHP.net - rawurlencode](http://us2.php.net/manual/en/function.rawurlencode.php)
189189

190-
#### Usual PHP Code (`require` solution)
190+
#### Usual PHP Code
191191
Usual PHP code means a simple created `file.php`, where you start writing your code like this:
192192

193193
```php
@@ -200,9 +200,12 @@ When you use this solution, you'll probably start using the TS3 PHP Framework l
200200

201201
```php
202202
<?php
203-
// load framework files
204-
require_once("libraries/TeamSpeak3/TeamSpeak3.php");
205-
203+
// load Composer dependencies and the framework's PSR-4 classes
204+
require_once __DIR__ . "/vendor/autoload.php";
205+
206+
use PlanetTeamSpeak\TeamSpeak3Framework\Exception\TeamSpeak3Exception;
207+
use PlanetTeamSpeak\TeamSpeak3Framework\TeamSpeak3;
208+
206209
try
207210
{
208211
// IPv4 connection URI
@@ -214,7 +217,7 @@ try
214217
// spawn an object for the channel using a specified name
215218
$ts3_Channel = $ts3_VirtualServer->channelGetByName("I do not exist");
216219
}
217-
catch(TeamSpeak3_Exception $e)
220+
catch(TeamSpeak3Exception $e)
218221
{
219222
// print the error message returned by the server
220223
echo "Error " . $e->getCode() . ": " . $e->getMessage();
@@ -229,7 +232,7 @@ When you use a MVC based software like Symfony, CakePHP, Laravel or something si
229232
<?php
230233

231234
use PlanetTeamSpeak\TeamSpeak3Framework\TeamSpeak3;
232-
use PlanetTeamSpeak\TeamSpeak3Framework\TeamSpeak3_Exception;
235+
use PlanetTeamSpeak\TeamSpeak3Framework\Exception\TeamSpeak3Exception;
233236

234237
class TeamspeakController extends Controller
235238
{
@@ -240,16 +243,13 @@ class TeamspeakController extends Controller
240243
// IPv4 connection URI
241244
$uri = "serverquery://username:password@127.0.0.1:10011/?server_port=9987";
242245

243-
// Create new object of TS3 PHP Framework class
244-
$TS3PHPFramework = new TeamSpeak3();
245-
246246
// connect to above specified server, authenticate and spawn an object for the virtual server on port 9987
247-
$ts3_VirtualServer = $TS3PHPFramework->factory($uri);
247+
$ts3_VirtualServer = TeamSpeak3::factory($uri);
248248

249249
// spawn an object for the channel using a specified name
250250
$ts3_Channel = $ts3_VirtualServer->channelGetByName("I do not exist");
251251
}
252-
catch(TeamSpeak3_Exception $e)
252+
catch(TeamSpeak3Exception $e)
253253
{
254254
// print the error message returned by the server
255255
return "Error " . $e->getCode() . ": " . $e->getMessage();

0 commit comments

Comments
 (0)