Skip to content
This repository
Browse code

use composer.json (temporarily define the facebook/php-sdk composer c…

…onfig in this package)
  • Loading branch information...
commit 0a0ea67fba6cc4f1fd1e05cd5107cdbf6e7f559c 1 parent dd5d1a0
Lukas Kahwe Smith authored March 08, 2012
8  .gitignore
... ...
@@ -1,6 +1,6 @@
1 1
 phpunit.xml
2 2
 coverage
3  
-vendor/facebook
4  
-vendor/symfony
5  
-vendor/twig
6  
-Tests/autoload.php
  3
+vendor
  4
+
  5
+composer.phar
  6
+composer.lock
7  .travis.yml
@@ -4,10 +4,9 @@ php:
4 4
   - 5.3
5 5
   - 5.4
6 6
 
7  
-env:
8  
-  - SYMFONY_VERSION=origin/master
9  
-
10  
-before_script: php vendor/vendors.php
  7
+before_script:
  8
+  - wget -nc http://getcomposer.org/composer.phar
  9
+  - php composer.phar install
11 10
 
12 11
 script: phpunit --coverage-text
13 12
 
35  Tests/autoload.php.dist
... ...
@@ -1,35 +0,0 @@
1  
-<?php
2  
-
3  
-/*
4  
- * This file is part of the FOSFacebookBundle package.
5  
- *
6  
- * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
7  
- *
8  
- * For the full copyright and license information, please view the LICENSE
9  
- * file that was distributed with this source code.
10  
- */
11  
-
12  
-$vendorDir = __DIR__.'/../vendor';
13  
-require_once $vendorDir.'/symfony/src/Symfony/Component/ClassLoader/UniversalClassLoader.php';
14  
-
15  
-use Symfony\Component\ClassLoader\UniversalClassLoader;
16  
-
17  
-$loader = new UniversalClassLoader();
18  
-$loader->registerNamespaces(array(
19  
-    'Symfony'                => array($vendorDir.'/symfony/src'),
20  
-));
21  
-$loader->registerPrefixes(array(
22  
-    'Twig_'            => $vendorDir.'/twig/lib',
23  
-));
24  
-$loader->register();
25  
-
26  
-spl_autoload_register(function($class) {
27  
-    if (0 === strpos($class, 'FOS\\FacebookBundle\\')) {
28  
-        $path = __DIR__.'/../'.implode('/', array_slice(explode('\\', $class), 2)).'.php';
29  
-        if (!stream_resolve_include_path($path)) {
30  
-            return false;
31  
-        }
32  
-        require_once $path;
33  
-        return true;
34  
-    }
35  
-});
20  Tests/bootstrap.php
@@ -9,8 +9,20 @@
9 9
  * file that was distributed with this source code.
10 10
  */
11 11
 
12  
-if (file_exists($file = __DIR__.'/autoload.php')) {
13  
-    require_once $file;
14  
-} elseif (file_exists($file = __DIR__.'/autoload.php.dist')) {
15  
-    require_once $file;
  12
+if (file_exists($file = __DIR__.'/../vendor/.composer/autoload.php')) {
  13
+    $autoload = require_once $file;
  14
+} else {
  15
+    throw new RuntimeException('Install dependencies to run test suite.');
16 16
 }
  17
+
  18
+spl_autoload_register(function($class) {
  19
+    if (0 === strpos($class, 'FOS\\FacebookBundle\\')) {
  20
+        $path = __DIR__.'/../'.implode('/', array_slice(explode('\\', $class), 2)).'.php';
  21
+        if (!stream_resolve_include_path($path)) {
  22
+            return false;
  23
+        }
  24
+        require_once $path;
  25
+        return true;
  26
+    }
  27
+});
  28
+
16  composer.json
... ...
@@ -1,4 +1,19 @@
1 1
 {
  2
+    "repositories": {
  3
+        "facebook-unofficial": {
  4
+            "type": "package",
  5
+            "package": {
  6
+                "name": "facebook/php-sdk",
  7
+                "version": "3.1.1",
  8
+                "source": {
  9
+                    "url": "git://github.com/facebook/php-sdk.git",
  10
+                    "type": "git",
  11
+                    "reference": "origin/master"
  12
+                }
  13
+            }
  14
+        }
  15
+    },
  16
+
2 17
     "name": "friendsofsymfony/facebook-bundle",
3 18
     "type": "symfony-bundle",
4 19
     "description": "Integrate the Facebook Platform into your Symfony2 application.",
@@ -22,6 +37,7 @@
22 37
         "symfony/symfony": ">=2.1.0-dev",
23 38
         "facebook/php-sdk": "3.*"
24 39
     },
  40
+
25 41
     "autoload": {
26 42
         "psr-0": { "FOS\\FacebookBundle": "" }
27 43
     },
36  vendor/vendors.php
... ...
@@ -1,36 +0,0 @@
1  
-#!/usr/bin/env php
2  
-<?php
3  
-
4  
-/*
5  
- * This file is part of the FOSFacebookBundle package.
6  
- *
7  
- * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
8  
- *
9  
- * For the full copyright and license information, please view the LICENSE
10  
- * file that was distributed with this source code.
11  
- */
12  
-set_time_limit(0);
13  
-
14  
-if (isset($argv[1])) {
15  
-    $_SERVER['SYMFONY_VERSION'] = $argv[1];
16  
-}
17  
-
18  
-$vendorDir = __DIR__;
19  
-$deps = array(
20  
-    array('symfony', 'http://github.com/symfony/symfony', isset($_SERVER['SYMFONY_VERSION']) ? $_SERVER['SYMFONY_VERSION'] : 'origin/master'),
21  
-    array('facebook', 'git://github.com/facebook/php-sdk.git', 'origin/master'),
22  
-    array('twig', 'http://github.com/fabpot/Twig', 'origin/master'),
23  
-);
24  
-
25  
-foreach ($deps as $dep) {
26  
-    list($name, $url, $rev) = $dep;
27  
-
28  
-    echo "> Installing/Updating $name\n";
29  
-
30  
-    $installDir = $vendorDir.'/'.$name;
31  
-    if (!is_dir($installDir)) {
32  
-        system(sprintf('git clone -q %s %s', escapeshellarg($url), escapeshellarg($installDir)));
33  
-    }
34  
-
35  
-    system(sprintf('cd %s && git fetch -q origin && git reset --hard %s', escapeshellarg($installDir), escapeshellarg($rev)));
36  
-}

12 notes on commit 0a0ea67

Matthieu Vachon

Is the composer.json ready to be used?

Christophe Coevoet
Owner
stof commented on 0a0ea67 March 09, 2012

@maoueh the only point is that you have to define the custom repository for the FB SDK in your base package as the SDK does not have a composer.json yet

Matthieu Vachon

Yeah that is what I thought. You probably saw the issue I logged on the composer repo. Is there, or will there, be a way to avoid the fact that end-user need to add the custom repository to their package definition?

Christophe Coevoet
Owner
stof commented on 0a0ea67 March 09, 2012

@maoueh There is no other solution. Custom repositories are used by composer to retrieve the list of available package to create the dependency solver. So you cannot add them from the deps as you don't know the deps at this time (it is the work of the solver to determine them)

Matthieu Vachon

Ok I understand the problem. Thanks for the explanations. In an other order of ideas, I tested the composer.json and everything is working fine.

Johannes
Owner

Can't the custom repository be added to the FOSFacebook composer.json?

Christophe Coevoet
Owner
stof commented on 0a0ea67 March 09, 2012

@schmittjoh As said previously, only the root package can define custom repositories as they are needed before knowing which packages should be installed as deps.

And currently, it defines it. But this is used only when FOSFacebookBundle is the root package, i.e. when running the testsuite

Johannes
Owner

It might be the behavior right now, but I don't see why it needs to stay this way?

Christophe Coevoet
Owner
stof commented on 0a0ea67 March 09, 2012

@schmittjoh because the solver needs to know the constraints to be able to solve them. And packages provided by additional repos cannot be registered in the solver before you know which packages should be installed (i.e. after solving the constraints)

Johannes
Owner

When you gather information about constraints, you at some point need to load the composer.json file. At this point, composer also sees that there is a repository defined in the file and could add it to its internal list. I don't see how composer could solve constraints without parsing the composer.json files of the different repositories that makes no sense.

Is/was there a ticket on the composer repository for this?

Christophe Coevoet
Owner
stof commented on 0a0ea67 March 09, 2012

@schmittjoh the issue is that you would then include the custom repositories defined by all packages available on packagist even where they are totally unrelated to your root package (as all their package definitions are loaded).
And it would mean making the Solver aware of all loaders whereas they are totally different and decoupled things currently.

Jordi Boggiano

See composer/composer#419 - I tried to explain in details why it's like it is.

Please sign in to comment.
Something went wrong with that request. Please try again.