Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP Building Websites with PHP Dependency Management Autoloading

Sergey Podgornyy
Sergey Podgornyy
20,660 Points

The following code doesn't work on my Workstation

The following code doesn't work on my Workstation.

I use Linux and code from Composer Website doesn't work on my local web server. Can you explain why?

// To avoid stupid questions: I have installed web server, php and also composer

Looking forward for your answers. Thanks in advance.

Sergey

composer.json is:

{
    "name": "sergey/php-website",
    "authors": [
        {
            "name": "Sergey Podgornyy",
            "email": "example@example.com"
        }
    ],
    "require": {
        "monolog/monolog": "^1.17"
    }
}

index.php is:

<?php
require 'vendor/autoload.php';

$log = new Monolog\Logger('name');
$log->pushHandler(new Monolog\Handler\StreamHandler('app.log', Monolog\Logger::WARNING));
$log->addWarning('Foo');

echo "Hello World";
Sergey Podgornyy
Sergey Podgornyy
20,660 Points

chmod 777 fixed this problem. Maybe someone know how to add composer to a group? Because right now everyone have permission to write (and create/delete any files) on my website folder.

1 Answer

Same thing, chmod 777 solved it, but as far as i get it's not a best practice ...

Sergey Podgornyy
Sergey Podgornyy
20,660 Points

I think it also possible to change owner or owner group. Or I found out that sometimes composer can be installed on wrong way