Skip to content

Commit b8280b8

Browse files
committed
Merge branch 'iamquan-patch-1'
2 parents d68e966 + 9f0ec10 commit b8280b8

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ Usage
2020
You can find many examples of how to use the dom parser and any of its parts (which you will most likely never touch) in the tests directory. The tests are done using PHPUnit and are very small, a few lines each, and are a great place to start. Given that, I'll still be showing a few examples of how the package should be used. The following example is a very simplistic usage of the package.
2121

2222
```php
23+
// Assuming you installed from Composer:
24+
require "vendor/autoload.php";
2325
use PHPHtmlParser\Dom;
2426

2527
$dom = new Dom;
@@ -36,6 +38,8 @@ Loading Files
3638
You may also seamlessly load a file into the dom instead of a string, which is much more convinient and is how I except most developers will be loading the html. The following example is taken from our test and uses the "big.html" file found there.
3739

3840
```php
41+
// Assuming you installed from Composer:
42+
require "vendor/autoload.php";
3943
use PHPHtmlParser\Dom;
4044

4145
$dom = new Dom;
@@ -67,6 +71,8 @@ Loading Url
6771
Loading a url is very similar to the way you would load the html from a file.
6872

6973
```php
74+
// Assuming you installed from Composer:
75+
require "vendor/autoload.php";
7076
use PHPHtmlParser\Dom;
7177

7278
$dom = new Dom;
@@ -81,6 +87,8 @@ $html = $dom->outerHtml; // same result as the first example
8187
What makes the loadFromUrl method note worthy is the `PHPHtmlParser\CurlInterface` parameter, an optional second parameter. By default, we use the `PHPHtmlParser\Curl` class to get the contents of the url. On the other hand, though, you can inject your own implementation of CurlInterface and we will attempt to load the url using what ever tool/settings you want, up to you.
8288

8389
```php
90+
// Assuming you installed from Composer:
91+
require "vendor/autoload.php";
8492
use PHPHtmlParser\Dom;
8593
use App\Services\Connector;
8694

@@ -97,6 +105,8 @@ Loading Strings
97105
Loading a string directly, with out the checks in `load()` is also easely done.
98106

99107
```php
108+
// Assuming you installed from Composer:
109+
require "vendor/autoload.php";
100110
use PHPHtmlParser\Dom;
101111

102112
$dom = new Dom;
@@ -112,6 +122,8 @@ Options
112122
You can also set parsing option that will effect the behavior of the parsing engine. You can set a global option array using the `setOptions` method in the `Dom` object or a instance specific option by adding it to the `load` method as an extra (optional) parameter.
113123

114124
```php
125+
// Assuming you installed from Composer:
126+
require "vendor/autoload.php";
115127
use PHPHtmlParser\Dom;
116128

117129
$dom = new Dom;

0 commit comments

Comments
 (0)