laravel new; application already exists error - php

I have installed Laravel before and I deleted that folder, and now after several months I install Laravel installer but when I write the command laravel new in Windows Powershell it returns this error.
_ _
| | | |
| | __ _ _ __ __ ___ _____| |
| | / _` | '__/ _` \ \ / / _ \ |
| |___| (_| | | | (_| |\ V / __/ |
|______\__,_|_| \__,_| \_/ \___|_|
In NewCommand.php line 153:
Application already exists!
new [--dev] [--jet] [-f|--force] [--] [<name>]

I created project. But I deleted it. When I create project again with the same name, I encountered this problem. After, I runned this command:
laravel new project-name --force
Only, I added --force end of command.

I have faced the same issue while creating a new project on the latest Laravel through Composer but didn't find any solution and at the last, I tried to create a Laravel project by the following command and it's working as expected.
composer create-project --prefer-dist laravel/laravel ProjectName
or, you should remove that folder and let it be created by command as follows:
laravel new ProjectName
Explanation:
As I get the following error.
_ _
| | | |
| | __ _ _ __ __ ___ _____| |
| | / _` | '__/ _` \ \ / / _ \ |
| |___| (_| | | | (_| |\ V / __/ |
|______\__,_|_| \__,_| \_/ \___|_|
In NewCommand.php line 184:
Application already exists!
new [--dev] [--jet] [--stack [STACK]] [--teams] [-f|--force] [--] [<name>]
I tried to figure out this issue and found a function that is placed under %appdata%\Composer\vendor\laravel\installer\src\NewCommand.php on line 184 as follows:
/**
* Verify that the application does not already exist.
*
* #param string $directory
* #return void
*/
protected function verifyApplicationDoesntExist($directory)
{
if ((is_dir($directory) || is_file($directory)) && $directory != getcwd()) {
throw new RuntimeException('Application already exists!');
}
}
here verifyApplicationDoesntExist function is checking that the application folder you are trying to create has existed or not, it's not checking the application folder's size so it doesn't matter if the folder is empty or not. so due to code like that, the composer thinks application already been created that's why it throws an error like your application already exists.
To tackle this issue, you just need to delete your empty project folder and create it by command laravel new ProjectName and that will create project folder itself without giving any error like Application already exist!.

If you're having problems, delete the parent directory. There's a chance there are hidden folders scattered across it.
Otherwise you can try creating a new folder in another directory and running Laravel new in it.
The folder location doesn't matter, it just generates content of a Laravel app.
Once you've created a new folder, you can move all the files across to your other folder with the following:
mv laravel/* /var/app/myfolderlocation

It happened to me too.
Maybe you created your laravel project directly in your linux shell instead of making it through the power shell "indirect" interface to your linux machine.
In my case I solved it following the next steps:
1.- Deleting the laravel-project directly in the ubuntu linux shell. rm -R laravel-project.
2.- Then, through power shell i executed again the curl command in the "sublinux" terminal like this: curl -s https://laravel.build/example-app | bash
Then the process started without problems, creating all the laravel files and docker images and containers.
All the tutorials followed by me direct to the microsoft step by step tutorial,
https://learn.microsoft.com/en-us/windows/wsl/install-win10
but it hidden some key steps that you can find in this amazing video:
https://www.youtube.com/watch?v=rr6AngDpgnM, thank you dogcomp for take the time that need some begginers (and not so beginners, like me).

change your Newcommand.php file
with github Newcommand.php file
https://github.com/laravel/installer/blob/master/src/NewCommand.php

The error means that the directory already exists.
Do the following to get around.
Go to a temp directory.
Execute the laravel new project-name there.
Copy the contents of the newly created directory to the actual project directory.

Though this might be late but i think it might help someone in difficult times. This error is related to the folder already in existence
Here's how i was able solve this issue:
i closed the vscode holding reference to the folder i intend installing laravel in. then
cd .. to come out from the folder.
next up. laravel new [target-folder-name] -f
and problem solved.
I'm hoping this would help someone.

While previously you would need to first create the directory then cd the console there and run laravel new, but currently you have to:
First ensure the my-project directory does NOT exist.
Run laravel new my-project to create the directory for you.
Wait for composer install command (which will auto-run) to finish.
For me in the end, it just logs Application ready! Build something amazing.
But finally, maybe go further and edit the auto-generated ./my-project/.env file, for example, set DB_DATABASE to something other than my_project or change APP_URL=http://my-project.test to APP_URL=http://localhost address.

Related

PSR-4 namespace in generated files with Thrift

I generate php files with Apache Thrift
thrift -out / --gen php:nsglobal=src\\Application\\Package\\Thrift package.thrift
The above command generates code in the following path src/Application/Package/Thrift and set src\Application\Package\Thrift for namespace but I use Psr-4 (with composer) in my project we know src as App so namespace should be App\Application\Package\Thrift
my project structure
src |
| Application |
| | Package |
| | | Thrift
I went generate files in Thrift folder with namespace same as following:
App\Application\Package\Thrift
Do you have an idea to solve this problem?
I try add namespace php App.Application.Package to IDL file and run following command:
thrift -out /src --gen php /data/service.thrift
But it create extra App folder => src/App/Application/Package/Thrift
Declare the namespace in the IDL file:
namespace php Whatever.You.Want
Full example can be found here
Also, remove the nsglobal option and just do
thrift -out / --gen php package.thrift
i need App in namespace and src in folder name
If you need the folder being different from what the namespace says, consider writing a shell script (or batch file) to move the generated files to where you need them to be after Thrift code generation.
PS: Not sure if specifying a root folder as the output target is such a great idea at all.

failed opening required in laravel warning and fatal error

laravel giving error failed opening required thrn (file path)(include_path='C:\xampp\php\PEAR')in (file path)
//my index file code id shown below
//require __DIR__.'public/vendor/autoload.php';
require_once $_SERVER['DOCUMENT_ROOT'].'public/vendor/autoload.php';
/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/
//$app = require_once __DIR__.'/public/bootstrap/app.php';
$app = require_once (realpath($_SERVER["DOCUMENT_ROOT"]).'/public/bootstrap/app.php';
If this is a new installation, you need to run composer install.
If it's an existing installation (vendor folder exists) run composer update.
Step 1:
Run: Composer Install for new Installation.
Run: Composer Update for Existing Installation.
Step 2: Make .env file
Step 3: Run: Php artisan migrate (Make database )
Step 4: Run: Php artisan key:generate

Adding php-curl in a Yocto build

I've been building a custom image using Yocto and wpewebkit to use within docker. I need to run a local web server with php, which I have accomplished no problem. I need to use curl within my project and I have apache2, php, modphp, and curl installed. All I need is php-curl but I cannot find how to install this. Does anyone know how or if I can do this? I've put in all my efforts on googling multiple phrases but I only find how to install php-curl using apt-get or yum, or I get links to the meta-* directories which I have access to within my build files anyways.
If it helps at all, this custom image was based on the image provided from the following project on GitHub: https://github.com/resin-io-playground/resin-wpe/tree/master/base-image . I already spoke to the developer and their knowledge of PHP is limited.
EDIT #1: Progress so far, had to update the curl.bb file to properly include libcurl-dev, and then worked with #pmod's suggestion to incorporate curl into the php build. Everything seemed to run okay until I received the following error:
| ../php-7.1.9/configure: line 386: test: please: integer expression expected
| configure: error: reinstall
| ../php-7.1.9/configure: line 275: return: please: numeric argument required
| ../php-7.1.9/configure: line 285: exit: please: numeric argument required
| NOTE: The following config.log files may provide further information.
| NOTE: /base-image/build/tmp-glibc/work/x86_64-linux/php-native/7.1.9-r0/build/config.log
| ERROR: configure failed
| WARNING: /base-image/build/tmp-glibc/work/x86_64-linux/php-native/7.1.9-r0/temp/run.do_configure.29590:1 exit 1 from 'exit 1'
| ERROR: Function failed: do_configure (log file is located at /base-image/build/tmp-glibc/work/x86_64-linux/php-native/7.1.9-r0/temp/log.do_configure.29590)
ERROR: Task (virtual:native:/base-image/build/../meta-openembedded/meta-oe/recipes-devtools/php/php_7.1.9.bb:do_configure) failed with exit code '1'
Edit #2: I've gone ahead and added everything I was missing. I'm getting the same error above, where the function do_configure during the php build is failing. I'm posting below what I ensured I have in my curl.bb file (I had to add this), what I have in my php.inc file, and the curl files located staging directory.
curl.bb:
PACKAGES =+ "lib${BPN} lib${BPN}-native lib${BPN}-dev lib${BPN}-dev-native"
FILES_lib${BPN} = "${libdir}/lib*.so.*"
FILES_lib${BPN}-dev = "${includedir} \
${libdir}/lib*.so \
${libdir}/lib*.a \
${libdir}/lib*.la \
${libdir}/pkgconfig \
${datadir}/aclocal \
${bindir}/*-config"
php.inc:
EXTRA_OECONF_append = " --with-curl=${libdir}/.."
DEPENDS_${PN} += "libcurl-dev libcurl-dev-native"
PHP Staging Directory:
/installeddeps/curl-native
/installeddeps/curl-native.b77f37db31cf2391919a12c5c9774bff
/installeddeps/curl-native.complete
/usr/share/aclocal/libcurl.m4
/usr/bin/curl-config
/usr/bin/crossscripts/curl-config
/usr/bin/curl
/usr/lib/pkgconfig/libcurl.pc
/usr/lib/libcurl.so
/usr/lib/libcurl.a
/usr/lib/libcurl.so.4.4.0
/usr/lib/libcurl.so.4
/usr/include/curl
/usr/include/curl/curl.h
/usr/include/curl/curlrules.h
/usr/include/curl/curlbuild.h
/usr/include/curl/curlver.h
/usr/include/curl/easy.h
According to php manual, PHP/cURL feature is enabled at php configuration stage with --with-curl=[dir] option.
I checked the main recipe include file php.inc and couldn't find such configuration option. So, try creating in your working layer php_%.bbappend file with (or add this directly to the bottom of php.inc to test):
EXTRA_OECONF_append_class-target = " --with-curl=${STAGING_LIBDIR}/.."
DEPENDS_append_class-target = " curl"
Note, that curl package among DEPENDS because it is needed at build stage.
I don't think you need to update curl recipe with PACKAGES and FILES, pkg_config should take care

How can I provide a script for PHP CLI via composer (as standalone, and as dependency)

I am attempting to write a PHP script that I would like to run from the command line. I want to use composer to manage its dependencies, as well as to make it available to be installed as a dependency to other projects. I also want to maintain the ability to use it on its own (with its dependencies).
Currently, main.php is my "entry point" (what I would execute from the command line). As I built and tested it, I did so in the "stand alone" mindset. A such, main.php requires autoload like so:
<?php
require_once __DIR__.'/../vendor/autoload.php';
Continuing in stand alone mindset, I set it up like so:
git clone package into place
cd package
composer install
This produces the following directory setup"
package
|-composer.json
|
|-src
| |-ClassOne.php
| |
| |-ClassTwo.php
| |
| |-main.php
|
|-vendor
|-autoload.php
|
|-composer
|
|-3rdpaty_1
|
|-3rdpaty_2
This works well--I can run php src/main.php which is able to find the classes it needs because it loads __DIR__.'../vendor/autoload.php'.
Where I run in to trouble is when I want to install the package as a dependency to another project (in order to have the script available to run there). I add my package to the composer.json and it gets installed. Attempting to run php vendor/compnay/package/src/main.php fails, however, because the necessary autoload.php is in a different place:
dependent_project
|-composer.json
|
|-some_code
|
|-vendor
|-autoload.php
|
|-composer
|
|-company
| |-package
| |-composer.json
| |
| |-src
| |-ClassOne.php
| |
| |-ClassTwo.php
| |
| |-main.php
|
|-other_vendor_1
|
|-other_vendor_2
I understand what is wrong, but I am not sure how to fix it. How does one provide such a thing using composer? I've searched around a lot but I don't see anyone asking or answering the same question. I notice the bin property of composer.json and started looking into that idea, but I'm still not finding a lot of info on how to properly set up my script to find what it needs in the different contexts.
I considered trying to use include in an if, and running a second include to the other path on fail, but that doesn't seem like the proper way to go about it.
A common practice is to look into both locations for an autoload file. See for instance this snippet used by Behat:
function includeIfExists($file)
{
if (file_exists($file)) {
return include $file;
}
}
if ((!$loader = includeIfExists(__DIR__.'/../vendor/autoload.php')) && (!$loader = includeIfExists(__DIR__.'/../../../autoload.php'))) {
fwrite(STDERR,
'You must set up the project dependencies, run the following commands:'.PHP_EOL.
'curl -s http://getcomposer.org/installer | php'.PHP_EOL.
'php composer.phar install'.PHP_EOL
);
exit(1);
}

unable to live site in server laravel5

iam getting an error after uploaded project to server. when i visited to link somedomain.com/DEMO i got following error. What actually is this error? how can i solve it please help me.
Warning: require(/home/siddins/public_html/DEMO/project/app/http/helpers/backend/helpers.php): failed to open stream: No such file or directory in /home/siddins/public_html/DEMO/project/vendor/composer/autoload_real.php on line 54
Fatal error: require(): Failed opening required '/home/siddins/public_html/DEMO/project/app/http/helpers/backend/helpers.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/siddins/public_html/DEMO/project/vendor/composer/autoload_real.php on line 54
my index.php is like this:
<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* #package Laravel
* #author Taylor Otwell <taylorotwell#gmail.com>
*/
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| our application. We just need to utilize it! We'll simply require it
| into the script here so that we don't have to worry about manual
| loading any of our classes later on. It feels nice to relax.
|
*/
require __DIR__.'/project/bootstrap/autoload.php';
/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/
$app = require_once __DIR__.'/project/bootstrap/app.php';
/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request
| through the kernel, and send the associated response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/
$kernel = $app->make('Illuminate\Contracts\Http\Kernel');
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
$response->send();
$kernel->terminate($request, $response);
project is main folder . Inside projetc i have app,vendor,bootstrap,config,database,resources etc
Here are some of the best practices while launching a Laravel app on server.
Try them out. Might solve your issues. These steps have solved almost every problem that I have faced till now while launching a site on server.
1.Enable Mod_Rewrite
a2enmod rewrite
2.Install php 5.6
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php5-5.6
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install php5
While returning views, always use Foldername.viewname instead of Foldername\viewname
use public_path() while including files
chmod -R 777 "Storage folder path"
This file doesn't exist:
/home/siddins/public_html/DEMO/project/app/http/helpers/backend/helpers.php

Categories