Why command "php artisan serve" not working - laravel

I started Laravel at this path:
C:\Users\Mad\Work\trunk\product\backend\v1.2.1\laravel
but it is not working, it is not starting.
Please give me suggestions how I will do it ?

try
php -S localhost:8000 -t public/
source : http://allbitsnbytes.com/posts/php-artisan-serve-not-working/

Try this also
php -S 127.0.0.1:8000 -t public/
https://www.tutsmake.com/laravel-command-php-artisan-serve-not-working-properly/

try to execute the command : composer update.
It will update and export all the directorys/files that u need.
because sometimes when u clone/download a repository from github .. there are pretty much directorys/files that are not present (not exportable .. present in .gitignor).
then try : php artisan serve.
it works for me

composer update
This will update and export directories and files and then run the below command :
php artisan serve
or you can also try this on your terminal:
php -S localhost:8000 -t public/

Just wanted to add to Jayhuan's answer above:
Laravel does the same thing behind the scenes, you can see the code here (look in serverCommand).
So to serve locally you would do:
php artisan serve --host mysite.com --port 8000

try only this
php -S localhost:8000

Your missing some Server Requirements
See the Laravel site for requirements.
Laravel Documentation
The Laravel framework has a few system requirements.
If you are not using Homestead, you will need to make sure your server meets the following requirements:
PHP >= 7.1.3
BCMath PHP Extension
Ctype PHP Extension
JSON PHP Extension
Mbstring PHP Extension
OpenSSL PHP Extension
PDO PHP Extension
Tokenizer PHP Extension
XML PHP Extension
To see a list of your extensions... From the command line:
$ php -m
I was missing BCMath and Tokenizer so I installed them with:
$ sudo apt-get install php-bcmath
$ sudo apt-get install php-tokenizer
Now you can use $ php artisan serve

Try the below code
php -S localhost:8000 -t public

I think you also check your path which you use in the composer like C:\Users\HP>
example:if your parent folder is blog then use
C:\Users\HP> cd blog/
C:\Users\HP>blog> php artisan serve

There could be multiple reasons for this problem one of the reasons is using old dependencies.
step 1: Check your current version of PHP and version of dependencies if they don't match proceed to next step.
step 2: replace the older dependencies with the newer one in composer.json file.
facade/ignition to ^2.3.6
laravel/framework to ^8.0
laravel/ui to ^3.0
nunomaduro/collision to ^5.0
phpunit/phpunit to ^9.0
The following first-party packages have new major releases to support Laravel 8. If applicable, you should read their individual upgrade guides before upgrading
Passport v10.0
Socialite v5.0
Telescope v4.0
Try to find the appropriate dependencies for your project and make sure u add the correct version of it in the composer.json file.
step 3: Now the next step is to update the composer
`composer update`
step 4: The last step is to run the artisan serve command.
php artisan serve
If all the dependencies are perfect then it will work. All the best.

Related

Laravel: [ErrorException] "continue" targeting switch is equivalent to "break". during "composer install"

When I run ...
composer install
... on a server with PHP and nginx installed.
I get the following exception:
[ErrorException]
"continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"?
How can I fix this?
This is a new warning introduced in PHP 7.3.
It means you are not allowed to have a continue statement inside of a switch, you should use break instead.
To fix this you most likely just have to update composer, this can be done simply by running composer self-update.
You can also just run php without warnings, this can be done by setting the ini config values as a start parameter.
php -d error_reporting=0 composer.phar
Check your current PHP version if it's greater than 7.2, then execute follow below simple steps
1. Disable the latest php version
sudo a2dismod php7.3
2. Restart the nginx service
sudo service nginx restart
3. If you are using Apache2 run as below
sudo service apache2 restart
4. Set alternatives
sudo update-alternatives --set php /usr/bin/php7.2
5. Check the PHP version
php -v
6. Now, Install Composer as below
composer install
Old composer uses continue statement in their code within the switch which is outdated and cannot be used anymore with latest version of php.
you need to update your composer
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php --install-dir=bin
for more details visit composer download
It was because of an outdated composer. After searching a lot finally the following works for me:
Uninstall the old composer.
Install a new updated composer.
You can download or install composer from this link: https://getcomposer.org/download/
For me,
just go to this file
sudo nano /usr/share/php/Composer/DependencyResolver/RuleSetGenerator.php
As a quick and dirty alternative, you can fix the error in that file. Just replace "continue" with "break"

Laravel 5.5 "Class 'PDO' not found"

Here is the actual error when I open the site
Actually, I have successfully run php artisan migrate:refresh, and there is no error.
Already tried the following command.
php artisan cache:clear
php artisan config:clear
composer install
composer clearcache
composer dump-autoload
php artisan clear-compiled
I also checked if pdo is installed, thru php -m and its already installed
I'm using CentOS.
What is most likely happening here is that the PDO module is enabled in the php-cli config (hence it works from command line), but is not enabled on the web server configuration file.
I am adding all possible options which can solve the issue
Add use PDO; after your namespace or just before your class or at the top of your PHP file
As you are using centOS try the below commands
yum install php-pdo
yum install php-pdo_mysql
service httpd restart
If still its not solved check the php.ini file path to see which is being loaded in the phpinfo() output.
Sometimes there are two different PHP versions installed on a machine, one for CLI and one for the web server.
Restart your apache, nginx, php-fpm
Run <?php phpinfo(); ?> and find out the /path/to/php.ini
Open php.ini
sudo nano /path/to/php.ini
Add these lines to enable the extensions
extension=openssl
extension=pdo_firebird
extension=pdo.so
extension=pdo_mysql
extension=pdo_oci
extension=pdo_odbc
extension=pdo_pgsql
extension=pdo_sqlite
Restart the server
sudo apachectl restart

Laravel 5.5 install not generating .env file

I have installed laravel 5.4 multiple times.
Now I'm trying to install laravel 5.5 using same command And it doesn't work.
composer create-project --prefer-dist laravel/laravel blog dev-develop
It doesn't seem to have any errors on installation, only lot of suggestions.
But no key is generated and no .env file is created.
When I try to make php artisan key:generate
/public_html/blog/.env): failed to open stream: No such file or directory
Got the same problem days a go, the problem was because composer was not updated, solved it updating composer, you can run:
composer self-update
Or you can download the latest version there, then you can create the project again and the .env file will be automatically created.
I have this version
Composer version #package_branch_alias_version# (1.0.0-beta2) 2016-03-27 16:00:34
When I run composer self-update I get
[InvalidArgumentException]
Command "self-update" is not defined.
shell command: cp .env.example .env
If you just want to make current setup work, just try doing the following:
cp .env.example .env
php artisan key:generate
But as suggested by one of the answers here, you should update your composer if you have an old version. To check your installed version, do so with composer -v
This is happening because of your Laravel Installer or Composer version. I have faced the same problem and found following 2 different solutions:
Generally, you can solve with by running composer global update command and then run composer update command from your project directory. This solution basically updates your installer and then your project.
If still, you have this problem, then you need to run composer self-update command first and then run composer update command from your project directory. It will update your composer version and then your project.
Hope this information will help you to fix.

how to make php artisan command available?

I read previous posts here about same problem but they did not solve my problem. I am running wamp latest version on windows 7 and I cloned a laravel app from github then I ran composer install on the root folder of the app and all vendors installed. however I still can not execute php artisan list on the app root folder
I tried also this command
composer global require "laravel/installer=~1.1"
but same problem also there is no laravel folder installed inside vendor folder. I dont know what laravel version used with this web app
So how I can make php artisan work ?
Update:
I opened composer.json file and I found no Laravel frame work to install !! should I return to the developer who made this or I just add Laravel package to composer.json and run composer install again ? if so what I should add to the composer.json ? I dont know which version to install !!
Your project has to have an artisan file in the root directory, otherwise the php artisan command won't work.
I had a similar issue. Fixed it by using the following command, which results in a clean installation.
composer create-project --prefer-dist laravel/laravel my-project
If errors occur, your CLI will show them.
Docs

Getting Error in installation of yii2 advance template

I'm new to Yii2, I'm trying to install yii2 application advanced template.
I did follow these steps:
1 - Download yii2-app-advanced zip file from https://github.com/yiisoft/yii2-app-advanced
Follow GETTING STARTED guide:
My vendor directory Show Empty.
Please help, thanks in advance
Installing via Composer
If you do not already have Composer installed, you may do so by following the instructions at getcomposer.org. On Linux and Mac OS X, you'll run the following commands:
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
On Windows, you'll download and run Composer-Setup.exe.
Please refer to the Composer Documentation if you encounter any problems or want to learn more about Composer usage.
If you had Composer already installed before, make sure you use an up to date version. You can update Composer by running composer self-update.
With Composer installed, you can install Yii by running the following commands under a Web-accessible folder:
composer global require "fxp/composer-asset-plugin:~1.0.3"
composer create-project --prefer-dist yiisoft/yii2-app-advanced basic
The first command installs the composer asset plugin which allows managing bower and npm package dependencies through Composer. You only need to run this command once for all. The second command installs Yii in a directory named basic. You can choose a different directory name if you want.
Note: During the installation Composer may ask for your Github login credentials. This is normal because Composer needs to get enough API rate-limit to retrieve the dependent package information from Github. For more details, please refer to the Composer documentation.
composer create-project --prefer-dist --stability=dev yiisoft/yii2-app-advanced basic
Yii2 Installation Following command:
(1) First install Composer (LINUX):
Locally:
curl -sS https://getcomposer.org/installer | php
OR
(1) First install Composer (WINDOWS):
C:\Users\username>cd C:\bin
C:\bin>php -r "readfile('https://getcomposer.org/installer');" | php
Note: If the above fails due to readfile, use the http url or enable php_openssl.dll in php.ini
C:\bin>echo #php "%~dp0composer.phar" %>composer.bat*
C:\Users\username>composer -V
Composer version 27d8904
(2) Yii2 framework online downloads:
Basic App:
php composer.phar create-project yiisoft/yii2-app-basic basic 2.0.0-beta
Advanced App:
php composer.phar create-project yiisoft/yii2-app-advanced advanced 2.0.0-beta
(3) Other App Settings Command:
php init
php yii migrate
Refrence
use composer cos you need composer in future too!
and after unzip the advance project in www or htdocs you should navigate to your project with cmd or terminal and type yii migrate after that again type composer update

Resources