Laravel: php artisan serve doesn't start - php

I've dug through a few of the other answers here and nothing seems to fit the bill. I'm probably going to leave some information out initially so just let me know what else you might need and thanks!
Currently running ubuntu 7, using composer and laravel both of which seem to be installed properly:
When I type 'php artisan serve' and 'php artisan serve --port:8000' into terminal I get this error:
PHP Warning:
require(/home/user/Projects/thingy/bootstrap/../vendor/autoload.php):
failed to open stream: No such file or directory in
/home/user/Projects/thingy/bootstrap/autoload.php on line 17 PHP
Fatal error: require(): Failed opening required
'/home/user/Projects/thingy/bootstrap/../vendor/autoload.php'
(include_path='.:/usr/share/php') in
/home/user/Projects/thingy/bootstrap/autoload.php on line 17
When I attempt to run 'php -S localhost:8000 -t public/' just as an attempt I get the following error upon refresh:
PHP 7.0.18-0ubuntu0.17.04.1 Development Server started at Thu Jul 6
09:15:36 2017 Listening on http://localhost:8000 Document root is
/home/user/Projects/thingy/public Press Ctrl-C to quit. [Thu Jul 6
09:15:40 2017] PHP Warning:
require(/home/user/Projects/thingy/bootstrap/../vendor/autoload.php):
failed to open stream: No such file or directory in
/home/user/Projects/thingy/bootstrap/autoload.php on line 17 [Thu
Jul 6 09:15:40 2017] PHP Fatal error: require(): Failed opening
required
'/home/user/Projects/thingy/bootstrap/../vendor/autoload.php'
(include_path='.:/usr/share/php') in
/home/user/Projects/thingy/bootstrap/autoload.php on line 17 [Thu
Jul 6 09:15:40 2017] 127.0.0.1:57214 [500]: / - require(): Failed
opening required
'/home/user/Projects/thingy/bootstrap/../vendor/autoload.php'
(include_path='.:/usr/share/php') in
/home/user/Projects/thingy/bootstrap/autoload.php on line 17
I checked to see if maybe a server was already running using the 'ps -ef | grep php' command in terminal and I don't see any servers running at all.
I have run 'composer install' and I get the following error:
Cannot create cache directory
/home/user/.composer/cache/repo/https---packagist.org/, or directory
is not writable. Proceeding without cache Cannot create cache
directory /home/user/.composer/cache/files/, or directory is not
writable. Proceeding without cache Cannot create cache directory
/home/user/.composer/cache/repo/https---packagist.org/, or directory
is not writable. Proceeding without cache Loading composer
repositories with package information Installing dependencies
(including require-dev) from lock file Your requirements could not be
resolved to an installable set of packages.
Problem 1
- Installation request for laravel/framework v5.4.28 -> satisfiable by laravel/framework[v5.4.28].
- laravel/framework v5.4.28 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
Problem 2
- Installation request for phpunit/php-code-coverage 4.0.8 -> satisfiable by phpunit/php-code-coverage[4.0.8].
- phpunit/php-code-coverage 4.0.8 requires ext-dom * -> the requested PHP extension dom is missing from your system. Problem 3
- Installation request for phpunit/phpunit 5.7.21 -> satisfiable by phpunit/phpunit[5.7.21].
- phpunit/phpunit 5.7.21 requires ext-dom * -> the requested PHP extension dom is missing from your system. Problem 4
- laravel/framework v5.4.28 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
- laravel/tinker v1.0.1 requires illuminate/console ~5.1 -> satisfiable by laravel/framework[v5.4.28].
- Installation request for laravel/tinker v1.0.1 -> satisfiable by laravel/tinker[v1.0.1].
To enable extensions, verify that they are enabled in your .ini
files:
- /etc/php/7.0/cli/php.ini
- /etc/php/7.0/cli/conf.d/10-opcache.ini
- /etc/php/7.0/cli/conf.d/10-pdo.ini
- /etc/php/7.0/cli/conf.d/20-calendar.ini
- /etc/php/7.0/cli/conf.d/20-ctype.ini
- /etc/php/7.0/cli/conf.d/20-exif.ini
- /etc/php/7.0/cli/conf.d/20-fileinfo.ini
- /etc/php/7.0/cli/conf.d/20-ftp.ini
- /etc/php/7.0/cli/conf.d/20-gettext.ini
- /etc/php/7.0/cli/conf.d/20-iconv.ini
- /etc/php/7.0/cli/conf.d/20-json.ini
- /etc/php/7.0/cli/conf.d/20-pdo_pgsql.ini
- /etc/php/7.0/cli/conf.d/20-pgsql.ini
- /etc/php/7.0/cli/conf.d/20-phar.ini
- /etc/php/7.0/cli/conf.d/20-posix.ini
- /etc/php/7.0/cli/conf.d/20-readline.ini
- /etc/php/7.0/cli/conf.d/20-shmop.ini
- /etc/php/7.0/cli/conf.d/20-sockets.ini
- /etc/php/7.0/cli/conf.d/20-sysvmsg.ini
- /etc/php/7.0/cli/conf.d/20-sysvsem.ini
- /etc/php/7.0/cli/conf.d/20-sysvshm.ini
- /etc/php/7.0/cli/conf.d/20-tokenizer.ini
- /etc/php/7.0/cli/conf.d/20-zip.ini You can also run php --ini inside terminal to see which files are used by PHP in CLI mode.
When running 'composer dump-autoload' I get the following:
Cannot create cache directory
/home/user/.composer/cache/repo/https---packagist.org/, or directory
is not writable. Proceeding without cache Cannot create cache
directory /home/user/.composer/cache/files/, or directory is not
writable. Proceeding without cache Cannot create cache directory
/home/user/.composer/cache/repo/https---packagist.org/, or directory
is not writable. Proceeding without cache Generating optimized
autoload files
After following the advice of Nishan Karunarathna and Alex I now get the following error when I run 'php artisan serve':
PHP Fatal error: Uncaught Error: Class
'Illuminate\Foundation\Application' not found in
/home/joshua/Projects/thingy/bootstrap/app.php:14 Stack trace:
0 /home/joshua/Projects/thingy/artisan(18): require_once()
1 {main} thrown in /home/joshua/Projects/thingy/bootstrap/app.php on line 14
Thanks for any help you give!

You have sort out the errors when encountered when doing composer install.
Install required PHP extensions
sudo apt-get install php7.0-mbstring
sudo apt-get install php7.0-xml
Then restart your nginx and try to run composer install again.

I think you should:
1) Install additional php extensions. Run into your terminal something like:
$ sudo apt-get install php7.0-opcache php7.0-calendar php7.0-ctype php7.0-gettext ...
2) Then give permissions to cache dir of composer:
$ sudo chmod -R u+w /home/joshua/.composer or if this directory is absent your should create its before $ sudo mkdir /home/joshua/.composer
3) Run $ composer install
But I'd like to pay your attention on:
1) Check your home directory on write permissions. If you don't have them, the most part of programs can't work correctly
2) Probably you have needed php extensions but they are not loaded. In this case check your .ini files and enable extensions.

Ok so I managed to answer my own question (actually a friend answered it for me.)
Apparently after you install laravel and composer it can, on occasion, lose the file path:
I had to open my .bashrc file in my hidden files on the /home/user/ level and add the command 'export PATH=~/.composer/vendor/bin:$PATH'
I think the other users here did contribute to fixing my problem as laravel and composer didn't seem to be installed correctly despite the files being in the proper place.

Related

How to solve memory limit and composer errors in Laravel project? [duplicate]

This question already has answers here:
Composer Memory Limit
(3 answers)
Closed 2 years ago.
When I run the Laravel project via php artisan serve I get an error about /vendor/autoload.php as no such file or directiory in /artisan. Then after I did couple of research I found that composer does not exist. Hence, I tried to update composer via composer update I get an error about the memory limit as such:
Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 67108864 bytes) in phar:///usr/local/Cellar/composer/1.10.7/bin/composer/src/Composer/DependencyResolver/Solver.php on line 223
And then I try to increase the memory to make the memory infinite with the command php -d memory_limit=-1 but then, terminal is not giving me a response.
I cloned the project through git and there is no .env file in my project. How can I solve the problem?
When I run composer install I get the errors below.
Problem 1
- Installation request for laravel/horizon v4.3.3 -> satisfiable by laravel/horizon[v4.3.3].
- laravel/horizon v4.3.3 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system.
Problem 2
- Installation request for phpoffice/phpspreadsheet 1.13.0 -> satisfiable by phpoffice/phpspreadsheet[1.13.0].
- phpoffice/phpspreadsheet 1.13.0 requires ext-zip * -> the requested PHP extension zip is missing from your system.
Problem 3
- phpoffice/phpspreadsheet 1.13.0 requires ext-zip * -> the requested PHP extension zip is missing from your system.
- maatwebsite/excel 3.1.19 requires phpoffice/phpspreadsheet ^1.10 -> satisfiable by phpoffice/phpspreadsheet[1.13.0].
- Installation request for maatwebsite/excel 3.1.19 -> satisfiable by maatwebsite/excel[3.1.19].
Did you try with the information listed over here
You can also try this command php -d memory_limit=-1 $(which composer) update
You may wanna check this topic aswell
Also
I had to combine COMPOSER_MEMORY_LIMIT and memory_limit in the command line:
On Windows:
set COMPOSER_MEMORY_LIMIT=99999999999&& php -d memory_limit=-1 composer.phar update
On Linux:
export COMPOSER_MEMORY_LIMIT=99999999999 && php -d memory_limit=-1 composer.phar update
This is the command that solves all problems I mentioned above.
composer install --ignore-platform-reqs

php dependency/package manager Composer will not install packages

I'm building a website with PHP framework "Slim" as my templating framework, and it recommends using composer as the package manager. SO... I'm now using composer for the first time, developing locally on 64 bit Ubuntu 16.04 and composer is not installing anything into my project.
I've followed the installation instructions on the Slim Framework & Composer websites to a tee.
Basically this is the order of what I've done:
Installed composer into /var/www/html directory [1.]
Created Slim project using Slim-Skeleton as a base
php composer.phar create-project slim/slim-skeleton slimLittleTest
Note: the php composer.phar create-project slim/slim-skeleton command automatically creates a composer.json file, I will put the contents of that file down farther in my question.
Change into that directory and run php composer.phar install
Nothing is installed!
If I try to run php -S localhost:8080 -t public public/index.php as you're now supposed to able to (from the Slim framework website homepage tutorial) I get the following error:
[Tue Sep 5 18:55:04 2017] PHP Fatal error: require(): Failed opening required '/var/www/html/slimLittleTest/public/../vendor/autoload.php' (include_path='.:/usr/share/php') in /var/www/html/slimLittleTest/public/index.php on line 12
[Tue Sep 5 18:55:05 2017] PHP Warning:
require(/var/www/html/slimLittleTest/public/../vendor/autoload.php): failed to open stream: No such file or directory in /var/www/html/slimLittleTest/public/index.php on line 12
This error of course makes sense because nothing got installed! There is no vendor/autoload.php because Composer hasn't installed anything. (By default Composer installs dependencies into the vendor folder in the root of your project)
SEPTEMBER 7th QUESTION UPDATE
From some comments down below, I've been alerted to the fact that something must have gone wrong on the command composer create-project, that my solution of just re-requiring all packages shouldn't be necessary. Upon further inspection, I did get some errors upon running command php composer.phar create-project slim/slim-skeleton projectName. Below is exactly what got output from the console after running that command:
php composer.phar create-project slim/slim-skeleton tester
Installing slim/slim-skeleton (3.1.2)
- Installing slim/slim-skeleton (3.1.2): Loading from cache
Created project in tester
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- phpunit/phpunit 5.7.9 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 5.7.8 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 5.7.7 requires ext-dom * -> the requested PHP extension dom is missing from your system.
[.......]
To enable extensions, verify that they are enabled in your .ini files:
- /etc/php/7.0/cli/php.ini
- /etc/php/7.0/cli/conf.d/10-mysqlnd.ini
- /etc/php/7.0/cli/conf.d/10-opcache.ini
- /etc/php/7.0/cli/conf.d/10-pdo.ini
- /etc/php/7.0/cli/conf.d/20-calendar.ini
- /etc/php/7.0/cli/conf.d/20-ctype.ini
- /etc/php/7.0/cli/conf.d/20-curl.ini
- /etc/php/7.0/cli/conf.d/20-exif.ini
- /etc/php/7.0/cli/conf.d/20-fileinfo.ini
- /etc/php/7.0/cli/conf.d/20-ftp.ini
- /etc/php/7.0/cli/conf.d/20-gettext.ini
- /etc/php/7.0/cli/conf.d/20-iconv.ini
- /etc/php/7.0/cli/conf.d/20-imagick.ini
- /etc/php/7.0/cli/conf.d/20-json.ini
- /etc/php/7.0/cli/conf.d/20-mbstring.ini
- /etc/php/7.0/cli/conf.d/20-mcrypt.ini
- /etc/php/7.0/cli/conf.d/20-mysqli.ini
- /etc/php/7.0/cli/conf.d/20-pdo_mysql.ini
- /etc/php/7.0/cli/conf.d/20-phar.ini
- /etc/php/7.0/cli/conf.d/20-posix.ini
- /etc/php/7.0/cli/conf.d/20-readline.ini
- /etc/php/7.0/cli/conf.d/20-shmop.ini
- /etc/php/7.0/cli/conf.d/20-sockets.ini
- /etc/php/7.0/cli/conf.d/20-sysvmsg.ini
- /etc/php/7.0/cli/conf.d/20-sysvsem.ini
- /etc/php/7.0/cli/conf.d/20-sysvshm.ini
- /etc/php/7.0/cli/conf.d/20-tokenizer.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
Would either that .ini extensions issue or Problem 1 php unit requires ext-dom issue be the main source of my problem?
I got lucky and stumbled upon an answer that worked in my situation.
I just had to run php composer.phar require [package_name], for each package name, and if it wasn't in composer.json yet that dependency would get installed. So what I needed to do was delete the composer.json file, then go back and require each package from it. Nothing else worked, such as php composer.phar update, or php composer.phar install.
So I ran php composer.phar require slim/php, php composer.phar require php, etc. from the command line and everything installed correctly.
This is potentially a failure of the getting started documentation from SlimFramework.com, It's not necessarily "wrong" because maybe it works in some/most situations, but they should at least address the potential for the problem I ran into, and a solution or way to avoid it.
EVEN BETTER SOLUTION
Turns out that the main error I was getting here is that I was missing ext-dom. Thank you to this badass #Anar Bayramov's answer on another StackOverflow question I know that I can get the missing ext-dom by simply downloading php7.0-xml.
sudo apt-get update
sudo apt-get install php7.0-xml
And BOOM! Now when I run php composer.phar create-project slim/slim-skeleton projectName all vendor packages are installed successfully and it works like a charm. Problem solved.

Symfony startup

I need help with creating a symfony project in ubuntu/eclipse i get a lot of warnings. i Use:
ubuntu: 15.04
eclipse: 4.5.0 mars
symfony feature: 1.1.0.20150705
I use Symfony Feature to create projects using a built in wizard.
Project details:
PHP version: 5.6
Symfony version: v2.7.3
Override composer.jason values: i use defaults
i get errors with app/bootstrap.php.cache
Maybe there is a good tutorial that might help me, but 'till now i haven't found one...
Maybe elipse isn't good for symfony project.
Here are some error messages:
!ENTRY com.dubture.composer.core 4 4 2015-08-06 20:49:38.196
!MESSAGE PHP Warning: require_once(/var/www/test3/app/bootstrap.php.cache): failed to open stream: No such file or directory in /var/www/test3/app/console on line 10
PHP Fatal error: require_once(): Failed opening required '/var/www/test3/app/bootstrap.php.cache' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/test3/app/console on line 10
and second
!ENTRY com.dubture.composer.core 4 4 2015-08-06 20:50:29.267
!MESSAGE Installing symfony/framework-standard-edition (v2.7.2)
- Installing symfony/framework-standard-edition (v2.7.2)
Loading from cache
Created project in test1
> SymfonyStandard\Composer::hookRootPackageInstall
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for sensiolabs/security-checker v2.0.5 -> satisfiable by sensiolabs/security-checker[v2.0.5].
- sensiolabs/security-checker v2.0.5 requires ext-curl * -> the requested PHP extension curl is missing from your system.
Problem 2
- sensiolabs/security-checker v2.0.5 requires ext-curl * -> the requested PHP extension curl is missing from your system.
- sensio/distribution-bundle v4.0.0 requires sensiolabs/security-checker ~2.0 -> satisfiable by sensiolabs/security-checker[v2.0.5].
- Installation request for sensio/distribution-bundle v4.0.0 -> satisfiable by sensio/distribution-bundle[v4.0.0].
thats a piece of the whole log file, those are the messages i get in gui.
Composer installation failed with an error (see second set of error messages) because it could not install all dependencies.
It says in the error message:
the requested PHP extension curl is missing from your system.
You need to install this extension for PHP to get all required files to get your project up and running.
When Symfony2 starts up, it need some of bootstrap cookies which will be removed, eventually. From my experience, 'bootstrap.php.cache' file existed for ACME bundle example pages, and It is not essential file.
The solution is simple.
You just need to create 'bootstrap.php.cache' file in /var/www/test3/app/ folder. The content of 'bootstrap.php.cache' can be blank.
touch bootstrap.php.cache
Hope this works well for you. Good luck!
It's possible that, you don't have right permission for read in these file, check this sudo chmod 755 in these file. If you haven't that file, create it how suggests YONGSOO KIM
The solution is simple. You just need to create bootstrap.php.cache
file in /var/www/test3/app/ folder. The content of bootstrap.php.cache
can be blank.
You can fix problem with versions of package sensiolabs/security-checker or generate bootstrap cache file like answer here https://stackoverflow.com/a/6884027/4356973

phpunit and CodeCoverage

I'm running a vagrant box w/ a simple lamp stack. I've installed phpunit globally via composer :
composer global require "phpunit/phpunit=4.1.*"
When I run phpunit I get the following error:
PHP Warning: require_once(PHP/CodeCoverage/Filter.php): failed to open stream: No such file or directory in /usr/share/php/PHPUnit/Autoload.php on line 46
HP Fatal error: require_once(): Failed opening required 'PHP/CodeCoverage/Filter.php' (include_path='/home/vagrant/.composer/vendor/phpunit/php-text-template:/home/vagrant/.composer/vendor/phpunit/phpunit-mock-objects:/home/vagrant/.composer/vendor/phpunit/php-timer:/home/vagrant/.composer/vendor/phpunit/php-token-stream:/home/vagrant/.composer/vendor/phpunit/php-file-iterator:/home/vagrant/.composer/vendor/phpunit/php-code-coverage:/home/vagrant/.composer/vendor/phpunit/phpunit:/home/vagrant/.composer/vendor/symfony/yaml:.:/usr/share/php:/usr/share/pear') in /usr/share/php/PHPUnit/Autoload.php on line 46
My research seems to imply that it's a problem with CodeCoverage not installing, but I'm having problems trying to get that installed. I've tried to install via composer and can't get it working.
Via Composer, I've tried adding to the global:
composer global require "phpunit/php-code-coverage": "3.0.*#dev"
and I get this output:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- The requested package phpunit/php-code-coverage could not be found in any version, there may be a typo in the package name.
Problem 2
- phpunit/phpunit 4.1.3 requires phpunit/php-code-coverage ~2.0 -> no matching package found.
- phpunit/phpunit 4.1.3 requires phpunit/php-code-coverage ~2.0 -> no matching package found.
- Installation request for phpunit/phpunit == 4.1.3.0 -> satisfiable by phpunit/phpunit[4.1.3].
Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your minimum-stability setting
see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.
Read <http://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.
Installation failed, reverting ./composer.json to its original content.
No clue what I'm doing wrong!
you need to reinstall code-coverage 2.0 first
composer global require "phpunit/php-code-coverage":"2.0.*#dev"
then you install phpunit
composer global require "phpunit/phpunit=4.1.*"

phpdocumentor v2 --template cli option invalid

From the docs when I run the following command
phpdoc -d ../../src/ -t /tmp/domain-model-docs --template="responsive-twig"
I get this error
ERROR: Unknown command-line option "--template=responsive-twig" encountered, use phpdoc -h for help
ERROR: Unknown command-line option "--template=responsive-twig" encountered, use phpdoc -h for help
The docs state
$ phpdoc -d "./src" -t "./docs/api" --template="clean"
However, in the help that option does not exist (phpdoc -h).
Has it been renamed?
After more work & investigation, I got the following error...
vagrant#packer-ubuntu-13:/var/www/opg-core-back-end$ vendor/bin/phpdoc.php
PHP Fatal error: Class 'Monolog\ErrorHandler' not found in /var/www/opg-core-back-end/vendor/phpdocumentor/phpdocumentor/src/phpDocumentor/Application.php on line 131
PHP Stack trace:
PHP 1. {main}() /var/www/opg-core-back-end/vendor/phpdocumentor/phpdocumentor/bin/phpdoc.php:0
PHP 2. phpDocumentor\Application->__construct() /var/www/opg-core-back-end/vendor/phpdocumentor/phpdocumentor/bin/phpdoc.php:26
PHP 3. phpDocumentor\Application->addLogging() /var/www/opg-core-back-end/vendor/phpdocumentor/phpdocumentor/src/phpDocumentor/Application.php:57
Then I found out that monolog was an older version due to the ElasticSearch client after specifying phpdocumentor to use v2.3 rather than v2.* in composer & got this error...
our requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for elasticsearch/elasticsearch 0.4.0 -> satisfiable by elasticsearch/elasticsearch[v0.4.0].
- phpdocumentor/phpdocumentor v2.3.0 requires monolog/monolog ~1.6 -> satisfiable by monolog/monolog[1.6.0, 1.7.0, 1.8.0, 1.8.x-dev].
- Can only install one of: monolog/monolog[1.6.0, 1.5.0].
- Can only install one of: monolog/monolog[1.7.0, 1.5.0].
- Can only install one of: monolog/monolog[1.8.0, 1.5.0].
- Can only install one of: monolog/monolog[1.8.x-dev, 1.5.0].
- elasticsearch/elasticsearch v0.4.0 requires monolog/monolog 1.5.0 -> satisfiable by monolog/monolog[1.5.0].
- Installation request for phpdocumentor/phpdocumentor 2.3 -> satisfiable by phpdocumentor/phpdocumentor[v2.3.0].
To generate the class diagram, I temporary removed ElasticSearch dependency from composer. Not a long term solution, but allowed me to get the domain model diagram.

Categories