I've created my laravel project with create-project beacause composer install didn't work.
cd to my project and then, when I try to use php artisan list or any artisan command it just says:
Could not open input file: artisan
How do I fix this? the vendor file is in the project
My composer.json:
{
"name": "vendor_name/package_name",
"description": "description_text",
"minimum-stability": "stable",
"license": "proprietary",
"authors": [
{
"name": "author's name",
"email": "email#example.com"
}
],
"require": {
"barryvdh/laravel-ide-helper": "^2.0"
}
}
path to my project:
c:\wamp\www\project1
Inside vendor, no folder named artisan is showed
Use the project's root folder
Artisan comes with Laravel by default, if your php command works fine, then the only thing you need to do is to navigate to the project's root folder. The root folder is the parent folder of the app folder. For example:
cd c:\Program Files\xampp\htdocs\your-project-name
Now the php artisan list command should work fine, because PHP runs the file called artisan in the project's folder.
Now install the laravel framework
Keep in mind that Artisan runs scripts stored in the vendor folder, so if you installed Laravel without Composer, like downloading and extracting the Laravel GitHub repo for laravel, then you don't have the framework itself and you may get the following error when you try to use Artisan:
Could not open input file: artisan
To solve this you have to install the framework itself by running composer install in your project's root folder.
Have you tried to do a "ls" (linux) or a "dir" (win) to make sure you are in the correct folder?
Check if you have correctly installed php.
Run cmd or shell and try to run
php -v
I'm going to assume you have Windows as your OS.
Go to Control Panel -> System and Security -> System -> Advanced system settings.
Then go to Environment Variables, find "Path" and add
;your/path/to/php.exe
at the end.
Replace "your/path/to/" with your current php.exe directory (including C:\ )
EDIT
Try with this one:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"laravel/framework": "5.0.*",
"barryvdh/laravel-ide-helper": "^2.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-create-project-cmd": [
"php -r \"copy('.env.example', '.env');\"",
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
}
}
I'm using windows 10, today is 31st dec, 2016.
I had the same issue, did a bit of a research and solved it.
First go to vendor directory from your laravel project directory and run this command:
composer install
if it further shows an error and asks for the composer.json file missing then:
cd ../
composer install
This fixed my issue!
I don't know if this has been solved, but I found this to be useful:
composer require laravel/passport --ignore-platform-req=ext-fileinfo
Related
My project is a Laravel implementation. I have created a composer.json file as follows:
{
"name": "company/project",
"description": "My cool project.",
"type": "project",
"license": "proprietary",
"require": {
"laravel/laravel": "8.*"
}
}
I can put this file in its own directory and run composer install. This installs version 8 of laravel/laravel and all dependencies in the vendor/ directory. But this is not a valid Laravel installation. If I then move the contents of vendor/laravel/laravel up into the main directory, copy .env.example to .env and run composer -o dump-autoload, then I have a directory structure that looks (as far as I can tell), just like a standard Laravel installation.
However, when I try to access the site from by browser, I get a 500 Server Error, with no apparent entries in the Apache or Laravel logs.
I know this is not an Apache configuration error because I can create exactly the same site using the command composer create-project laravel/laravel:8.* {directory}, and I get a function basic Laravel site.
My ultimate goal is to use composer to install my project AND Laravel, with all of it's dependencies, and get a functioning site. I am particularly interested in being able to lock all of the dependencies (including the specific version of laravel/laravel) via the composer.lock file, which will then be included with the version-controlled source of my project.
You may ask why I don't just use the recommended command to create a clean Laravel installation and just version-control the resultant composer.lock file. The reason is: That file does not contain the specific version of laravel/laravel. So when I then user the composer.json/lock files in a clean directory, the core laravel/larvel files are missing.
Any pointers as to what I am doing wrong? Or is there a simpler way to achieve my goal?
Your composer.json only requires "laravel/laravel": "8.*", but Laravel needs a lot more to function properly. When I do a composer create-project laravel/laravel it generates a composer.json with the following:
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"php": "^7.3|^8.0",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1",
"laravel/framework": "^8.54",
"laravel/sanctum": "^2.11",
"laravel/tinker": "^2.5"
},
"require-dev": {
"facade/ignition": "^2.5",
"fakerphp/faker": "^1.9.1",
"laravel/sail": "^1.0.1",
"mockery/mockery": "^1.4.2",
"nunomaduro/collision": "^5.0",
"phpunit/phpunit": "^9.3.3"
},
"autoload": {
"psr-4": {
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"#php artisan package:discover --ansi"
],
"post-update-cmd": [
"#php artisan vendor:publish --tag=laravel-assets --ansi"
],
"post-root-package-install": [
"#php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"#php artisan key:generate --ansi"
]
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"minimum-stability": "dev",
"prefer-stable": true
}
Now this does a lot more than just requiring a vendor-folder, these contain the namespace-declarations, scripts, and the requirements for a few more things.
And also note that this requires laravel/framework instead of laravel/laravel.
All in all I suggest using the full list from here and keep stripping until it breaks if you want to.
And on the subject of version pinning, you could either put the composer.lock-file in your VCS and only run composer install (that does not update if there is lock-file).
You could also remove the ^ from all the versions that you don't want to update, that way you can restrict a version with some room for updates if you want. 8.0.1 would keep at 8.0.1, but you could allow patches by specifying 8.0.* as a version-requirement.
In the end, I gave up trying to make this work. Instead, I now follow these steps to install a new site:
composer create-project --no-install --no-scripts laravel/laravel:{version} {SITE}
cd {SITE}
svn export --force {repo}/composer.json .
svn export --force {repo}/composer.lock .
composer install
svn co {repo} .
svn -R revert .
This allows me to create a site with the specific version of Laravel that I need.
For last 3 days, I am trying to install laravel 5.5 in my system(windows 8.1) through composer and getting a series of errors one after other. So I am asking some questions in order to clear my doubts which are still doubted after more than 20-25 hour of research on various blogs and SO.
I have installed php 7 in c:\php.
After that, I have installed composer using composer installer and did nothing after that, like setting PATH on environment setting.
I found that I have to create a composer.json file which I have copied from Github and shown below, but I don't know where to keep this composer.json file so I created this file on C:\Users\MyPC (i.e. my home directory).
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=7.0.0",
"fideloper/proxy": "~3.3",
"laravel/framework": "5.5.*",
"laravel/tinker": "~1.0"
},
"require-dev": {
"filp/whoops": "~2.0",
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~6.0"
},
"autoload": {
"classmap": [
"database/seeds",
"database/factories"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"extra": {
"laravel": {
"dont-discover": [
]
}
},
"scripts": {
"post-root-package-install": [
"#php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"#php artisan key:generate"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"#php artisan package:discover"
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
}
}
Please check the code above if I have committed any mistake.
After that I executed "composer update" command which downloaded a lot of files and placed in C:\Users\MyPC\vendor folder (I think), but throws an error at last which I can't remember.
After that I executed "composer install" command and get this error shown below.
This is my problem and I am not able to figure out what to do.
I have a couple of more doubt:
a - composer create-project --prefer-dist laravel/laravel NAME_OF_PROJECT can also be used to set up new project then why we use composer global require “laravel/installer” and then laravel new NAME_OF_PROJECT method. What are the benefits of using this method.
b - What are the steps to follow after the installation of the composer using the installer for setting up a new laravel project. What are the best practices to structure the project folder?
Please help me. I am learning laravel but don't know how to deal with this composer stuff and installing laravel as most or all of the tutorial starts with creating new project file .they don't teach how to install them.
Ok so a lot of research and try and errors I figured out a way that worked for me. I am using Windows 8.1.
I have installed php 7 in c:\php.
Note : Download php from
http://php.net/downloads.php. Download Non Thread Safe
version in zip format and extract it to the
desired folder (I extracted in C:\php).
After that I have installed composer using composer installer and did nothing after that, like setting PATH on environment setting, Installer will do it for you.
Download Composer Installer from https://getcomposer.org/download/.
After that I have downloaded laravel from github and exctrated to the desired project folder.
Download Laravel latest version from https://github.com/laravel/laravel
After that I ran "composer self-update"command.
After that I ran "composer update"command.
After that I ran "composer global require “laravel/installer”"command. This command will install Laravel Installer.
Now I can go to the project folder directory and run "laravel new myProjectName" command to create new laravel project.
For some reason I started getting this error after a few days. I didn't change anything from the time my Laravel application was working to the time it threw this parse error:
Parse error: syntax error, unexpected T_USE, expecting T_FUNCTION in /home/fzystudi/public_html/vendor/laravel/framework/src/Illuminate/Support/Str.php on line 7
Here is the site live with error.
Here is what I tried for solving the errors:
I wiped everything clean and installed laravel again. Same error. So I then did composer update. Still no change. I did composer update again and still no change.
I also downloaded the developer version and stable version. Still no difference.
I cloned the exact file from str.php and the file is the same on github as it is in my app on my ftp server.
I uploaded to hostgator and A2 hosting. Same error on both sites.
Here is the thread on the laravel forum I posted. No one has been able to help yet.
What seems to be the cause and what is the fix?
This is my controller:
<?php
class SiteController extends BaseController {
public function __construct() {
//parent::__construct();
$this->beforeFilter('csrf', array('on'=>'post'));
}
//homepage for our store
public function getIndex() {
return View::make('site.index');
}
}
My composer.json:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"laravel/laravel": "4.1.*"
},
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
},
"minimum-stability": "stable"
}
This sounds like you're getting the bleeding edge version of Laravel which has started to make use of traits. I'm assuming line 7 of the Str.php file in your vendor directory is something like this?
use MacroableTrait;
You should check your composer.json file to make sure you're depending on the stable release of Laravel 4.1.
"laravel/laravel": "4.1.*"
You may need to delete your vendor directory again as well as the composer.lock file. If you don't remove the lock file you'll just re-install the same dependencies again. Once installed you can check the version you have by running artisan --version from your command line in the installed directory.
Earlier today my Laravel app on Fortrabbit was working fine but after pushing to the app white pages started to be displayed instead of any content. I can still directly access any assets by explicitly specifying the path but if I try to access my index page or any other that work both locally and on previous versions of the application I get a white screen with no content.
I've tried removing the /vendor directory and composer.lock and updating composer to get a fresh start. I've also looked into the logs given by the Fortrabbit service in the php and apache directories and neither are reporting errors. I've also looked into the logs for Laravel and this also didn't provide any error messages that could help me debug the issue.
Was wondering if anyone had experience with this issue and could offer steps to attempt to resolve it, thank you!
Notes:
I'm using Laravel v4.1.*
The commit that began causing the issue contained no changes to PHP code (only SCSS files)
I've run php artisan dump-autoload already
I can run php artisan tinker and interact with the MySQL database just fine with my models
My composer.json file:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"laravel/framework": "4.1.*",
"way/generators": "dev-master"
},
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
}
}
I'm using the Laravel framework and wanted to include a library from GitHub. This is my full composer.json file:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"laravel/framework": "4.0.*",
"intervention/helper": "dev-master" <- this is what I've added
},
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/validators",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan optimize"
],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
},
"minimum-stability": "dev"
}
I've added "intervention/helper": "dev-master" under the require directive and when I do composer update on my local copy of the website, everything works fine and I can use the library.
I did a git push and pull to get it onto my live server, and when doing a composer update it doesn't download this library. This is the entire output of the command: http://pastebin.com/UgPNTaDw
I also tried composer install and composer update for a second time but neither worked. I've also verified that git retrieved the new composer.json file on the live server, and it has.
Why isn't composer recognizing the changes and downloading the library?
Besides the fact that your log does exactly tell you the "missing" library was downloaded, I have some general comment:
Are you sure you want to use EVERY library in DEVELOPMENT quality? Because that is what you enabled with the "minimum stability" flag: You are allowing EVERYTHING in possibly broken state from whatever development branch the libraries provide.
And the second thing is: You are supposed to update only once, on your development machine! Then test that everything still is working, and commit the composer.lock file!
Then push and pull that change to wherever you need it, and there only composer install - because you probably want the exact SAME library versions that you tested with, not anything slightly newer with possibly broken commits.
If you only want to use that particular library as development version, you should add that flag to the version requirement:
"intervention/helper": "dev-master#dev"
On the other hand, this library has released versions, so it might be better to require them...