I have multiple projects with very little space to keep.
since most of them uses nearly same packages (only 1 uses phpexcel and the other one swiftmailer ) and vendor folder required biggest space on laravel.
I thought maybe I could use same vendor folder for every of them.
I actually messed with autoload.php and some other config files however I couldn't make it.
simply I'll put vendor folder under public_html and create folder like project1 project2.
under those folders I'll put everything about my projects except vendor folder and then make them subdomain.
Short answer:
You can't.
Long answer:
/vendor folder is not just about packages, you also have in there vendor/composer folder, where your application classes names are stored for autoloading purposes. Everytime you run composer dump-autoload, Composer changes the content of some files there. Take a look at the vendor/composer/autoload_classmap.php file, you'll see that some of those classes are from your own project.
Workaroud:
Please note that I don't see a thing like this going well, but you can, actually, create a blank project, just for package downloading and symlink all packages from all your vendors folders to that one. It's a lot of trouble for a little gain. But it's up to you, of course.
Source: http://www.wenda.io/questions/2416709/laravel-4-1-vendor-directory-config.html
edit composer.json
"config": {
"preferred-install": "dist",
"vendor-dir": "../vendor"
},
edit bootstrap/autoload.php file
require __DIR__.'/../../vendor/autoload.php'
edit bootstrap/start.php file
$framework = $app['path.base'].
'/../vendor/laravel/framework/src';
edit ../vendor/laravel/framework/src/Illuminate/Foundation/Console/Optimize/config.php
$basePath = $app['path.base'].'/../';
then run composer install, you will find vendor dir created ../
php artisan optimize -v --force
Generating optimized class loader
Compiling common classes
Related
By default node_modules folder is under the root directory of my Laravel project and it's working fine. I can compile the scripts with npm run dev and there is no error.
However according to the project folder structure, I move node_modules folder into a child folder called backend.
Here, I also moved the files like webpack.mix.js, package.json into backend folder and run npm install again inside it. But I keep my resources and public folders as original and link them with relative path via backend folder.
The folder structure looks like this
Now, if I run npm run dev inside backend folder, it complains many errors like can't resolve '#babel/runtime/regenerator'.
But if I make a symbolic node_modules inside root folder which is linked to backend/node_modules, it works fine and I can compile the scripts without error.
My question is - How can I compile the scripts from child folder without making a symbolic like this?
Probably it doesn't know where node_modules folder is located.
As laravel-mix is based on webpack. I add the modules path inside webpack config as below to make all import knows where the node_modules folder is located.
mix.webpackConfig({
resolve: {
modules : [
path.resolve("./node_modules")
]
}
});
There is no more can't resolve error.
A quick question:
which files or directories from Laravel 8 needs to be transferred to a production system or Muße the entire files and directories?
Well, yes, you have to move all the files including the vendor directory which has all the php dependencies (unless you can run composer install in production, in that case there's no need to upload the vendor directory). If you have local logs and cache in the storage directory, you can omit those.
You will also need to create a new .env file for production.
And, if your are using JavaScript with Laravel Mix, you don't need to upload the node_modules folder, only the compiled js or css files.
I've got a project which holds third party files (installed with Bower) under src/public/vendor. It seems ever since I added those docpad has gotten considerably slower in generating ./out, no doubt cause it's going over all the vendor files.
I'd like to exclude the vendor files from being interpreted by DocPad, but they should still be copied to ./out.
Is there a built-in way to do this through DocPad or should I simply put the vendor files outside the src directory and have Grunt copy it manually to ./out?
Your issue is legit and I raised the same a while ago :
https://github.com/bevry/docpad/issues/276
In the end, hypercubed developed the "raw" plugin available through npm :
https://npmjs.org/package/docpad-plugin-raw
Depending on what you provide as options, it can either do a cp or a rsync command.
So it basically what you intend to do with a Grunt task.
I've just started using the Composer feature where you tell it to look at local directories for dependencies, so that you can develop a library and something that uses that library in parallel without having to push to git to update all the time, which is awesome. e.g.
"repositories": [
{
"type": "vcs",
"url": "/documents/projects/github/guzzle"
}
],
"require":{
"guzzle/guzzle": "3.7.*#dev"
}
So when you do a composer update, Composer will pull in the version of Guzzle from the local directory, so you can test the code for a library in another application that uses that library without having to push to a repository between each code change.
However I just almost checked in the composer.json for my project with that set - which is obviously not going to work on anyone elses machine.
Is there anyway to tell composer to use a different file than composer.json, or other way to be able to tell composer to use local directories safely, without the high probability of accidentally committing a broken version of composer.json to your repository?
Use the COMPOSER environment variable:
env COMPOSER=composer-dev.json composer install
It has actually been available since at least 2012.
Instead of fetching from a local repository elsewhere you could add the option --prefer-source to the composer install/update command and remove the local repository reference.
That way composer will call git clone the software into the vendor directory, and you can develop both your software and commit to the vendor software, because that also is a fully working git repo.
Adding local repository references is not really recommended. It works when using them for real local software, but maintaining it has it's overhead: You have to mention this repository in every composer.json file that will ever load that software, even if it is only an indirect dependency (i.e. you add a software that needs THIS software as a dependency in your local repo).
Hardcoding the URL of the repository will also prevent you from changing it at will. Even though you could move the repo and change the URL accordingly, all older versions of your software still have the old URL in both composer.json and composer.lock files, and will try to load from there.
It looks like there isn't a way to do this nicely within Composer, however it is possible to hack around it.
In your composer.json file put a comment where you want to hack in some data.
{
"name": "base-reality/intahwebz",
"//": "LOCALHACK",
"require":{
"base-reality/php-to-javascript": ">=0.1.17",
"guzzle/danackguzzle": "3.3.*#dev",
...
...
}
...
}
Then have a separate file composer.local (not committed to Git) that contains the references to local directories:
"LOCALHACK",
"repositories": [
{
"type": "vcs",
"url": "/documents/projects/github/intahwebz-core"
}
],
Add a tiny PHP script called composerLocal.php to generate the new composer.json file
<?php
$srcFile = file_get_contents("composer.json");
$hackFile = file_get_contents("composer.local");
$finalString = str_replace('"LOCALHACK",', $hackFile, $srcFile);
file_put_contents("composer.json", $finalString);
?>
And a little bash script called localupdate.sh to backup the real composer.json file, generate the hacked composer.json, run Composer and then restore the original composer.json file
cp -f composer.json composer.json.bak
php composerLocal.php
composer update
cp -f composer.json.bak composer.json
Running the localupdate.sh script allows you to test the commits locally without having the danger of modifying the actual composer.json file used by the project, so there is less chance of accidentally pushing an invalid composer.json into the repository.
Just to note, Composer doesn't read the files from the respository directory, it reads the commited files in Git so you do need to commit changes made to the library code. The above process just skips the pushing step.
This should also work:
composer config --file=composer2.json && composer install
see https://getcomposer.org/doc/03-cli.md#usage
Easy, just use artifact.
In repositories add this:
{
"type": "artifact",
"url": "path/to/artifact/files/"
},
Now you just need to create the directory and zip a copy of your repository into that dir.
Name zipped files like so:
[vendorname]-[packagename]-[version].zip
example:
querypath-QueryPath-3.0.0.zip
Now you can modify the package locally and it will pull from the zip file instead of the online repo.
In require add it like so and specify version as defined in zip:
"querypath/QueryPath": "3.0.0",
With this method you will have the ability to edit the vendor files and composer will still update any autoloaders relative to the changes and it will leave your changes alone.
in a fresh silverstripe installation (3.0.5) there are many files where I wonder if I will ever need them or what their purpose is... so what I would like to have is a clean silverstripe installation and delete all unnecessary files/folders.
For what do I need these files/folders?:
phpunit.teamcity.mssql.xml
phpunit.teamcity.postgresql.xml
phpunit.teamcity.sqlite3.xml
phpunit.teamcity.xml
phpunit.xml.dist
test.php
web.config
vendor
many thanks for the clarification.
Florian
PHPUNIT / TeamCity
phpunit.teamcity.mssql.xml
phpunit.teamcity.postgresql.xml
phpunit.teamcity.sqlite3.xml
phpunit.teamcity.xml
phpunit.xml.dist
those are files used to configure php unit and team city (team city is a continuous integration software by jetbrains https://www.jetbrains.com/teamcity/)
(if you don't use teamcity, you can safely delete this files)
Web Server Config
.htaccess
this is the configuration file for apache web servers (if you don't use apache, you can delete this file)
web.config
this is for Microsoft IIS web servers, it is the equivalent to the .htaccess (if you don't use IIS as web server you can delete this file)
GIT (Version Control System)
.git/
.gitignore
.gitatributes
if you don't use git, you don't need them
Composer
composer.json
vendor/
the composer file holds information of php dependencies and where to get them.
the vendor folder is the folder where composer installs its dependencies
(composer is a php dependency manager which I can really recommend http://getcomposer.org/)
(if you do not use composer, you don't need them)
PHP files
index.php
fallback file in case mod_rewrite or the ISS equivalent is not working
install.php
the installer for SilverStripe, this file should be deleted after you installed SilverStripe
install-frameworkmissing.html
part of the installer
behat
behat.yml
I can't say much about behat because I don't use it, here is a quote from the website (http://behat.org/): "A php framework for testing your business expectations."
All I can say is that you can delete the file if you don't use behat
Other
test.php
no idea, I have never seen this file
README.md
obviously the readme file
CONTRIBUTING.md
a info file containing information on guidelines for contributing back to SilverStripe
Makefile
build.xml
Can't exactly say how to use those 2 files, but unless you do use them, you can delete them safely
tl;dr
the only files you really need is one of those 2:
if you are using apache (linux and mac but also windows) then you need to keep .htaccess
if you are IIS (windows server) then you need web.config
and the index.php if mod_rewrite is not available on your server
all other files are just for 3rd party software the core developers use