Another possibility is that the CLI version is using a different php.ini file. (By default, it'll use php-cli.ini and fallback to the standard php.ini)
Also, if you're using .htaccess files to set your library path, etc. this obviously won't work via the cli.