How to properly duplicate a working Laravel 4 project - laravel

I have the latest Laravel 4 beta 5 build from Laravel's github repo.
I have built a simple web API and it is working fine. I wanted to duplicate the project to another folder and continue working on it from the copy. However, when I try that, I get the following error message:
InvalidArgumentException
Driver [native] not supported.
/Users/tolga/Sites/l4api-copy/bootstrap/compiled.php
Line 10908: throw new \InvalidArgumentException("Driver [{$driver}] not supported.");
Here is what I did in order to copy the project:
[/Users/tolga/Sites] $ cp -R l4api l4api-copy
[/Users/tolga/Sites] $ chmod -R 755 l4api-copy
It didn't work, so I've tried:
[/Users/tolga/Sites] $ chmod -R 777 l4api-copy/app/storage
Still no good, tried to run composer dump-autoload:
[/Users/tolga/Sites] $ cd l4api-copy
[/Users/tolga/Sites/l4api-copy] $ composer.phar dump-autoload
Generating autoload files
[/Users/tolga/Sites/l4api-copy] $
Same error. I have also tried to remove the app/storage folder and re-create it.
[/Users/tolga/Sites/l4api-copy] $ rm -Rf app/storage
[/Users/tolga/Sites/l4api-copy] $ mkdir app/storage
[/Users/tolga/Sites/l4api-copy] $ chmod -R 777 app/storage/
Here is a brand-new error:
ErrorException
Warning: file_put_contents(/Users/tolga/Sites/l4api-copy/bootstrap/../app/storage/meta/services.json):
failed to open stream: No such file or directory in
/Users/tolga/Sites/l4api-copy/bootstrap/compiled.php line 5507
Line 5507: return file_put_contents($path, $contents);
I have also run composer.phar dump-autoload command again, after emptying the app/storage folder.
And finally, I have also tried composer.phar install:
[/Users/tolga/Sites/l4api-copy] $ composer.phar install
Loading composer repositories with package information
Installing dependencies from lock file
Nothing to install or update
Generating autoload files
[/Users/tolga/Sites/l4api-copy] $
None of the above helped. What am I doing wrong? What is the proper way to duplicate a working project?

After a recent commit to the laravel/laravel repository a new session driver, native, has been introduced. From the looks of your errors you should update your application skeleton (the cloned develop branch of laravel/laravel), delete your bootstrap/compiled.php file and re-run composer update to pull in the latest framework changes.
In terms of copying the project you should copy over everything except the vendor directory then run composer install in the new location. You could copy the vendor directory but it's better to run a clean install and let composer dump a new autoload.
I've also seen Taylor mention a cleanup of your app/storage/sessions directory. Delete all the files in there.

Related

I can't install composer globally in my web host, how can I use the "composer" command?

I hosted my website on french host Gandi, with their simple hosting plan.
I cannot move anything in the /usr/local/bin directory since it is read-only, so I used to manage with composer.phar, which works well.
I recently used a library which requires the composer executable to be present (This library executes something like "composer require xxx" and there is no fallback to composer.phar).
Is there a way to make it work ?
What I have done so far :
Tried to install composer globally (Failed because of the read-only filesystem)
Tried to install composer globally for the current user (Failed because there was no ~/.local/bin directory, and also failed after creating the directory and restarting the instance)
Tried to move the file to any directory of the $PATH variable (Failed because all of these directories are read-only)
Tried to rename composer.phar to composer, and allowed it to be executable chmod +x composer (Failed because it only works with the command ./composer and not with composer)
Ok, I finally succeeded with the following steps:
renamed composer.phar to composer mv composer.phar composer
made this new file executable chmod +x composer
added the current path (corresponding to my website's root) to the system's $PATH variable export PATH=$PATH:$PWD
I'm not fully satisfied with this since this relies on a specific website's root folder, but hey, it works! I'll try to update this answer if I find a way to create a folder available for every website I'll host there.

Symfony cannot install new bundles because of composer permission issue

While try to install new bundles into my project composer issue happens which is regarding permission, issue follows
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installRequirementsFile handling the symfony-scripts event terminated with an exception
Installation failed, reverting ./composer.json to its original content.
[Symfony\Component\Filesystem\Exception\IOException]
Failed to copy "/var/www/html/myProject/vendor/sensio/distribution-bundle/Composer/../Resources/skeleton/app/check.php" to "bin/symfony_requirements" because target file could not be opened for writing.
Thank you...
this might help you:
sudo chmod -R 777 bin/symfony_requirements
check if other directory and files need permission, for example in my case:
sudo chown -R $USER web/
was also needed.
furthermore if you had problem with cache and logs you may find following useful:
rm -rf var/logs
rm -rf var/cache
rm -rf vendor
and then using composer install
You have wrong permissions on file bin/symfony_requirements. Fix it and all will work like a charm

Error on "storage/framework/services.json" laravel 5 project

I have a project in laravel 5 in my notebook (windows), I created a repository for it in bitbucket and decided to use on my desktop (ubuntu 14). But for some reason they are showing several errors. And I'm new in version 5, I searched but could not understand the reason for the errors.
My .gitignore:
vendor/
node_modules/
# Laravel 4 specific
bootstrap/compiled.php
app/storage/
# Laravel 5 & Lumen specific
bootstrap/cache/
storage/
.env.*.php
.env.php
.env
# Rocketeer PHP task runner and deployment package. https://github.com/rocketeers/rocketeer
.rocketeer/
After cloning a repository within the htdocs of xampp, I used the following commands:
1) composer install
2) chmod 777 -R storage
3) chmod 777 -R bootstrap
but when opening http://localhost/myProject/public/
Whoops, looks like something went wrong.
1/1 ErrorException in Filesystem.php line 75:
file_put_contents(/opt/lampp/htdocs/myProject/storage/framework/services.json):
failed to open stream: No such file or directory
Run the commands the correct way:
chmod -R 777 storage
chmod -R 777 bootstrap
i.e. the -R flag needs to come after chmod.

what is phpmd and how to use it?

I have Ubuntu 14.04 + Sublime text 3 and installed phpcs packages
additionalty I have installed phpcs and php-cs-fixer on my system
From this blog
I have found that phpmd (PHP Mess Detector) is also a required library, so installed phpmd as per given instructions on official php md page using alternative method From the github repository everything was finished.
:~/phpmd$ curl -s http://getcomposer.org/installer | php
#!/usr/bin/env php
All settings correct for using Composer
Downloading...
Composer successfully installed to: /home/keshav/phpmd/composer.phar
Use it: php composer.phar
but now when I write on terminal
phpmd /opt/lampp/htdocs/myproject, myfile.php
phpmd: command not found
There is phpmd folder on Home directory and everything without any error.
I have local project on core PHP create composer.json in project folder as per suggested on github .
Please tell me what means by
Then install Composer in your project (or download the composer.phar directly):
I think the problem is you've installed phpmd in a local directory, but you're trying to use it as if it was installed globally.
Installation instruction on the referenced sites can't really be made any clearer. Since you've already installed phpcs and php-cs-fixer, and those work for you, just follow similar instructions for phpmd. These are all PHP projects and are installed in a similar way.
Anyway, to use phpmd as a global command you have several options.
Github
Clone the github repository just like you did and add the phpmd bin directory to your PATH variable.
Global composer installation
Use the composer global command to install phpmd globally. You will also need to make sure that composer's bin directory is in the PATH. By default it's ~/.composer/vendor/bin.
composer global require phpmd/phpmd
This command will install phpmd globally, and as soon as ~/.composer/vendor/bin is in your PATH you'll be able to call it by simply invoking phpmd.
It's very well explained in composer's documentation: https://getcomposer.org/doc/03-cli.md#global
Download the phar archive
This is the simplest thing you can do. Simply go the phpmd releases, choose the latest and download the phar archive.
Put the phar file to whatever place you'd like. Just remember that it needs to be in your PATH. You can also rename it, to skip the .phar extension.
For example:
wget http://static.phpmd.org/php/2.1.3/phpmd.phar
sudo mv phpmd.phar /usr/bin/phpmd
sudo chmod +x /usr/bin/phpmd
Docker container
First, fetch the docker image with static analysis tools for PHP:
docker pull jakzal/phpqa
One of the tools provided by the image is phpmd. The command below will run phpmd in a docker container and mount the current working directory as a /project.
docker run -it --rm -v $(pwd):/project -w /project jakzal/phpqa \
phpmd src text cleancode,codesize,controversial,design,naming,unusedcode
When you use the composer-based install, it gets installed into the ./bin directory within the ./vendors directory. So for me, relative to my project's root directory, it was here:
./vendor/bin/phpmd
And I was able to run it from my project's root by running ./vendor/bin/phpmd . text codesize. (I'm not getting any useful output yet, but another issue)

laravel application moved to another pc

I have just transferred my laravel application to another pc and I have installed composer. I am running composer install at the root of the project but it shows the following error:
{"error":{"type":"ErrorException","message":"file_put_contents(\/meta\/services.
json): failed to open stream: No such file or directory","file":"C:\\national-fl
eet\\vendor\\laravel\\framework\\src\\Illuminate\\Filesystem\\Filesystem.php","l
ine":71}}
I tried CACLS -R 755 app/storage (as admin)
and then composer update but the same error. bootstrap/compiled.php doesn't exists in my project. What should I do?
I got this error, because some folders in /app/storage were missing
To fix the error, I manually created the following folders:
app/storage/
app/storage/cache/
app/storage/logs/
app/storage/meta/
app/storage/sessions/
app/storage/views/
then delete the contents of my vendor folder and run composer update again
Try to remove the services.json in /meta (or rename it to something else) and try composer install again (or composer update). It is possible that the file hasn't got the correct rights for Laravel to write to.

Resources