I'm just playing around with Laravel and Composer, and I wanted to know if I can change where Laravel is located, but still be able to run composer in the root? The root folder is getting really busy with node_modules, bower_components, docs, bin, all my .*rc files, compass.rb, gruntfile.js, bower.js, composer.json, and package.json.
I was hoping I could dump Laravel into its own folder, but still be able to use composer.json to handle dependencies without having to change directories, so I can do all my CLI commands for grunt, bower, and composer at the same level.
Thinking of something very similar to .bowerrc where I can dictate where bower.json and bower components get stored.
Something like, but allow CLI in root for everything:
/root
.git
/bin
/bower
/components
bower.json
/config
/docs
/laravel
everything laravel instead of in root
composer.json? or out in root?
/node_modules
/sql
db.sql
gruntfile.js
package.json
.gitignore
.gitattributes
all .*rc files x 6, such as: .bowerrc, .jshintrc, etc
README.md
LICENSE.md
Yes. Just change the path of the auto-loader in bootstrap/autoload.php.
Related
This is my first deployment in Symfony 5 and I've been struggling a couple days with deployment because my website is showing a blank page.
I'm using Infinity Free Web Hosting with:
PHP Version 7.3.6
Apache
My website doesn't have a db.
So before I start to upload files with FileZilla, I run this commands:
SET APP_ENV=prod
composer install --no-dev --optimize-autoloader
composer dump-autoload --optimize --no-dev --classmap-authoritative
My folder structure goes like this
htdocs
\css
\downloads
\images
\scripts
.env.local
.htaccess
index.php
\symfony
\bin
\config
\src
\templates
\translations
\vendor
\var
composer.json
And modified index.php with new path:
require dirname(__DIR__).'symfony/vendor/autoload.php';
The issue is that the page is showing completely blank (not even an error). What is my mistake?
I've been following instructions with this tutorial, create a "symfony" folder with bin, config, src, templates and vendor, and I copied my "public" folder content to /htdocs folder.
Hosting provider doesn't allow me to upload content at the server root folder.
Thanks in advance.
You missing a / on your require :
require dirname(__DIR__).'/symfony/vendor/autoload.php';
Maybe use dev environment for debugging your application.
You have a .env.local : are you sure is necessary and correctly read ? (symfony/dotenv is a devDependency by default)
And I think is not a good practice to have your symfony folder and index.php on same directory because it can expose your source code and sensitive data. Maybe use htaccess to expose only symfony public directory.
I have an existing Laravel project I want to clone from GitHub.
I normally run Laravel on Homestead/Vagrant.
But this time I need to run it on Mamp.
I already cloned the project into my htdocs folder.
When I click to see my website, I see Index of/ then all the files.
Index of/
.env.example
.git/
.gitattributes
.gitignore
.phpintel/
app/
artisan
bootstrap/
composer.json
composer.lock
config/
database/
gulpfile.js
package.json
phpunit.xml
public/
readme.md
resources/
scratch3.php
server.php
storage/
tests/
What do I need to do/change/configure so my Laravel website works properly.
I'm on a Mac.
According to my experience, there are some steps for setting up an existing Laravel project as follows:
Install PHP and Composer
In your Laravel dir, run composer install
Then copy .env.example file to .env
Open .env and change a database connection information and save file
Generate the application key by using a command php artisan key:generate
Run a migration if exist by using a command php artisan migrate
Then run composer dump-autoload
Finally, start your project with command php artisan serve or create a shortcut in a public directory or Mamp and link it to public folder of your Laravel project.
Hope this helps, any comment is welcome.
if you click your website and you see your root you probably need to configure your settings a bit, maybe this will help
How to get htaccess to work on MAMP
I working with code igniter v3.x and I would like to add some composer packages.
looking at application/config/config.php file, it says that will load packages inside application folder
| package auto-loader script in application/vendor/autoload.php.
However in the codeigniter package it already has a package.json that installs packages on root folder.
I suspect that the package.json on the root must hold only information about CodeIgniter it self. But I'm not sure.
So I have three options:
Create a new package.json inside the application folder and install packages inside application.
Modify the package.json on the root folder by adding new package and change autoload.php location
What is expected from a CodeIgniter Application?
Well, if you take a look at the Codeigniter Documentation you can see there is a Configuration setting called composer_autoload. This information can be found here.
If you set this true, Codeigniter tries to load Composer's autoload.php in the APPLICATION.'vendor' folder. If you take a closer look at the Codeigniter.php file, you'll see that you can define a directory for this setting too.
So in your case you don't have to change the package.json in the root folder because you need one in the application folder, in case you set composer_autoload to true, which i would recommend.
By the way if you try to install a package via composer in your application directory, composer asks you if you want to use the one it found on the root folder - just decline that and press n.
As you can see in the picture below (i just tried to install the mpdf package).
Lately I've been learning about phpspec and gulp and decided to integrate them in my workflow.
When I installed phpspec via composer, I get the file structure of:
vendor
bin
phpspec
there are more files but and folders but these are the relevant.
In my CMD I'm currently pointing the root of my project and trying to run:
vendor/bin/phpspec
However, I get an error saying 'vendor' isn't recognizes as internal or external command...
so I moved into my bin folder by doing cd vendor/bin and then run phpspec and it indeed works. However, when I try to describe a class phpspec describe SeatsHandler it creates my files not in the root directory it creates them inside the vendor/bin folder:
vendor
bin
phpspec
spec
src
I tried to see how I can configure that and read about phpspec.yml. I've created such file along with app directory in my main folder (would love to get rid of app directory):
suites:
app_suite:
src_path: app
I tried putting this file in my main directory, but it didn't work, I got the same result as before. I also tried moving this file into vendor/bin but no avail.
How can I make phpspec create the files in my root directory instead of inside vendor/bin? Also, why does it ignore the phpspec.yml?
EDIT:
I managed to make it work by modifying my phpspec.yml into:
suites:
app_suite:
src_path: ../../src/
spec_path: ../../
And put it in vendor/bin. However, a question still remains, how can I run phpspec without going inside the vendor/bin directory in CMD?
in your composer.json file, just add the "bin-dir": "bin" under config like so:
{
"require-dev": {
"phpspec/phpspec": "~2.0"
},
"config": {
"bin-dir": "bin"
},
"autoload": {"psr-0": {"": "bin/src"}}
}
and youll get a bin folder on your root directory along with the vendor directory.
bin
vendor
then you can run phpspec on your root directory exactly as you want.
You can install it globally as following;
composer global require phpspec/phpspec
now you can call it phpspec
All,
I have a module in "vendor" directory. I don't want to check in any contents in the vendor directory. So, I changed my .gitIgnore file like this:
nbproject
._*
.~lock.*
.buildpath
.DS_Store
.idea
.project
.settings
composer.lock
vendor
But, git is still recognizing the vendor directory as modified and asking me to check it in.
How do I fix this?
Thanks
You should add directories to your .gitignore directory followed by a "/".
tim#roflcopter ~/htdocs/laravel $ cat .gitignore | grep vendor/
vendor/