Procházet zdrojové kódy

Update README.md

Added more descritive code snippets
Luiz Guilherme Fonseca Rosa před 8 roky
rodič
revize
ee00f48572
1 změnil soubory, kde provedl 29 přidání a 22 odebrání
  1. 29 22
      README.md

+ 29 - 22
README.md

@@ -40,12 +40,12 @@ Add the facade to your `config/app.php` file:
 
 ```php
 
-    'facades'       => array(
+    'aliases'       => [
 
         //...
         'Curl'          => Ixudra\Curl\Facades\Curl::class,
 
-    ),
+    ],
 
 ```
 
@@ -164,27 +164,34 @@ In order to send a `GET` request, you need to use the `get()` method that is pro
 Post requests work similar to `GET` requests, but use the `post()` method instead:
 
 ```php
+use Ixudra\Curl\Facades\Curl;
 
-    // Send a POST request to: http://www.foo.com/bar
-    $response = Curl::to('http://www.foo.com/bar')
-        ->post();
-
-    // Send a POST request to: http://www.foo.com/bar
-    $response = Curl::to('http://www.foo.com/bar')
-        ->withData( array( 'foz' => 'baz' ) )
-        ->post();
-
-    // Send a POST request to: http://www.foo.com/bar with arguments 'foz' = 'baz' using JSON
-    $response = Curl::to('http://www.foo.com/bar')
-        ->withData( array( 'foz' => 'baz' ) )
-        ->asJson()
-        ->post();
-
-    // Send a POST request to: http://www.foo.com/bar with arguments 'foz' = 'baz' using JSON and return as associative array
-    $response = Curl::to('http://www.foo.com/bar')
-        ->withData( array( 'foz' => 'baz' ) )
-        ->asJson( true )
-        ->post();
+class Foo
+{
+    public function bar ()
+        {
+        // Send a POST request to: http://www.foo.com/bar
+        $response = Curl::to('http://www.foo.com/bar')
+            ->post();
+
+        // Send a POST request to: http://www.foo.com/bar
+        $response = Curl::to('http://www.foo.com/bar')
+            ->withData( array( 'foz' => 'baz' ) )
+            ->post();
+
+        // Send a POST request to: http://www.foo.com/bar with arguments 'foz' = 'baz' using JSON
+        $response = Curl::to('http://www.foo.com/bar')
+            ->withData( array( 'foz' => 'baz' ) )
+            ->asJson()
+            ->post();
+
+        // Send a POST request to: http://www.foo.com/bar with arguments 'foz' = 'baz' using JSON and return as associative array
+        $response = Curl::to('http://www.foo.com/bar')
+            ->withData( array( 'foz' => 'baz' ) )
+            ->asJson( true )
+            ->post();
+        }
+}
 
 ```