Viewed   99 times

I have recently installed Laravel 5 via composer. I tried creating a new controller using artisan and I get the following error:

bootstrap/../vendor/autoload.php. Failed to open stream: No such file or directory. The "vendor" folder does not exist.

Am I missing something?

 Answers

3

Turns out I didn't enable openssl in my php.ini so when I created my new project with composer it was installed from source. I changed that and ran

composer update

now the vendor folder was created.

Sunday, October 23, 2022
5

Try to disable your anti-virus, this happens to me, it seems avast deletes my server.php.

So I added it to the exception

Monday, November 28, 2022
 
amar
 
4

The var_dump() output is correct. $xml->StatusCode is a SimpleXMLElement instance. This is of course needed in case you have to, for example, add a child element to it:

$xml->StatusCode->addChild("test", "value");

If $xml->StatusCode contained only the value of the element rather than an instance of SimpleXMLElement, you wouldn't be able to do any modifications on the loaded XML.

So, what you need to do, is cast the value of StatusCode to a string. There are various ways of doing this:

var_dump($xml->StatusCode); // returns SimpleXMLElement instance
var_dump((string)$xml->StatusCode); // explicitly
var_dump($xml->StatusCode->__toString()); // explicitly, calling the magic function
echo $xml->StatusCode; // implicitly

Some demos

Wednesday, October 19, 2022
 
traviso
 
2

After a long search, the solution is to remove the profile from scopes in vendorlaravelsocialitesrcTwoGoogleProvider.php

protected $scopes = [
    'openid',
    'email',
];
Wednesday, December 21, 2022
 
2

I don't think it's possible to use only function when you have code in your classes. Well, you could try with extending Blade but it's too much.

What you should do is creating one extra file, for example appHelpershelpers.php and in your composer.json file put:

"autoload": {
    "classmap": [
        "database"
    ],
    "psr-4": {
        "App\": "app/"
    },
    "files": ["app/Helpers/helpers.php"] // <- this line was added
},

create app/Helpers/helpers.php file and run

composer dump-autoload

Now in your app/Helpers/helpers.php file you could add those custom functions for example like this:

if (! function_exists('fooBar')) {
   function fooBar() 
   {
      return AppHelpersCustomHelper::fooBar();
   }
}

so you define global functions but in fact all of them might use specific public methods from some classes.

By the way this is exactly what Laravel does for its own helpers for example:

if (! function_exists('array_add')) {
    function array_add($array, $key, $value)
    {
        return Arr::add($array, $key, $value);
    }
}

as you see array_add is only shorter (or maybe less verbose) way of writing Arr::add

Friday, August 5, 2022
 
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :