I have a working Laravel 5.1 site. I have multiple packages that are in my vendor directory as well as the workbench directory. For the most part, when I edit one of the packages, I instantly see my changes. However, I have one package that Laravel is looking at the vendor directory only, so no matter what changes I make to controllers, models, or views for this package in the workbench directory, nothing changes. If I make any change in the vendor directory, that change is immediately seen. When I first came in this morning, I was able to edit the controller and see my change, but I was having issues with Laravel saying that it could not find the view. I ran a php artisan optimize and that fixed the issue of the view not being found, but now this Laravel only looks for code for this package in the vendor directory, not workbench.
Does anyone have a suggestion of what I can try to get Laravel to acknowledge the package in the workbench directory as apposed to the Vendor directory?
I did check permissions to see if the server just didn't have access to this directory, but that is not the case, it has the appropriate permissions.
Related
I've been trying to create an admin panel for Laravel (I know, there is a Laravel Nova now for 99$ for a single site) and all I've been doing is trying to build all of this functionality on top of laravel/laravel package.
What I've seen with Nova, is that it is a separate package, which is seamlessly integrates with Laravel by simply dragging and dropping the folder with Nova to the root directory of the Laravel application.
Even though, I have an idea (and a little bit of experience) on how to replicate (and maybe even enhance Nova functionality), I've no idea on how to make HMR working with the package.
Let's say my package name is Niva (just an example), with the folder named niva placed inside the Laravel folder. The webpack.mix.js is the same as in the Laravel Horizon package.
So far, I've no problems with accessing routes defined in the package, I'm able to load views from the package by accessing specified route, even authentication works just fine. However, I have to manually compile the package first, then publish the assets, and only then I can view the changes I've made to the source code.
Example package base routes:
Web: _http://localhost/niva (Only need for HMR to be present here)
Api: _http://localhost/api/niva
Example package base directories and files:
Root: /var/www/localhost/niva
Public: /var/www/localhost/niva/public
Resources: /var/www/localhost/niva/resources
Webpack: /var/www/localhost/niva/webpack.mix.js
What I'm asking about is: is it possible to enable HMR for the package, and how it should be done?
P.S. I've been thinking of symlinking the public directory from the package to the public vendor/niva folder, but still no result (I'm pretty sure I'm missing something here).
I've been running a project written in Laravel which has been fun to use.
The setup I use is the vagrant box Homestead configuration so I do the majority of my work on my local machine and push up to the development server once its ready to go. During the installation I had to push up the logs & vendor folder for it to work properly but now I'm at a stage where every commit I do via the command line includes storage/logs/laravel.log which when I then pull down it asks me to stash/commit on the server because they're different.
I've added it to the .gitignore file in the root directory of the project and it looks like this:
/node_modules
/public/storage
/.idea
Homestead.json
Homestead.yaml
/storage/logs/
/vendor/
Vendor doesn't cause me any problems unless I make changes to it so its not much of a bother, its just the logs which will not stop going up. If I use a GUI tool, I can manually tell it not to go up but I want to get it to the point that I can use the terminal to push it up and not worry about logs need stashing on the server.
I believe this is the same for the .env so I imagine a solution will work for both. I have also noticed that PHPStorm have said they're ignored but tracked with git if that helps.
If you take a look at the Laravel repo on GitHub, you'll find the following .gitignore file in the storage directory:
https://github.com/laravel/laravel/blob/master/storage/logs/.gitignore
This comes with the default installation to mark the logs directory as ignored. If you've deleted this by mistake, you should be able to reinstate it and resolve the issue you're having.
Just as importantly though, your workflow isn't following best practice. With respect to "Vendor doesn't cause me and problems unless i make changes to it" - you should never make changes to your vendor directory. This folder is home to third-party packages and plugins, modifying them directly causes multiple issues, chief amongst them:
You can no longer update a modified package without breaking your application.
Other developers won't be able to replicate your installation easily.
In fact, the vendor directory shouldn't be versioned at all. The best way to handle the files within it is using a package manager, like Composer, to do it all for you. This means you can easily switch between different versions of your packages and, by versioning only the composer files, other developers can run composer install or composer update to synchronise their development environment to yours quickly and accurately.
I had a website created in Laravel 4.2, its live and had to make some changes in it. To make these changes I had to use a package that wasn't used before, so I required the package and did composer update.
The new package that I've used, has created a folder inside app/config/packages.
Besides the controllers and views where I've made the changes, what files I'll have to upload now? Composer update command has updated a few packages and downloaded the new one.
I just want to know whether I'll have to re-upload whole site or there are some specific files or folders that I can upload and get the website working perfectly.
Ok, I have spent good time over this and figured it out.
Changes due to newly installed package:
I used a package to export data to excel Maatwebsite/Laravel-Excel. I had to to add service provider, alias and do composer update. The package created few config files in app/config/packages/maatwebsite folder.
Other Changes:
Apart from above mentioned things, when I did composer update, it updated composer, symphony, monolog, phpoffice and autoload.php inside vendor folder. It also created new folder called maatwebsite inside vendor. Apart from these, the views and controllers I changed myself to export data to excel.
So, I basically uploaded all the following to my website:
controller, views files I changed.
composer.json & composer.lock files.
Files & Folders inside vender (vendor/autoload.php, vendor/composer, vendor/symfony, vendor/phpoffice, vendor/maatwebsite)
Config files of newly installed package i.e. (app/config/packages/maatwebsite)
Finally my app/config/app.php file where I added service provider and alias
And the website is working perfectly fine. So there was no need to upload everything. :)
Hope this will be helpful for others.
If you have a proper deployment plan, having the composer update command run once the code has been deployed would fix all of that. Otherwise, you're going to have to upload everything that is new, and everything that has changed.
If the directory is empty, you're going to have to manually create it on the server. I would imagine that besides that directory, it'd be any published content, such as configs and what not, the package folder, composer.json and the composer autoload.
I want to deploy a Laravel 5 project to shared hosting from my localhost but I am facing so many problems. I have uploaded all files in a subfolder of my shared hosting (PHP 5.5) and when I try http://domain.com/subfolder/public its showing me 500 error. I check the laravel.log but found nothing, set the storage/ to 777 but still no changed (showing last error from localhost).
I also check .htaccess and it seems good. I search a lot and try so many thing but still facing same problem.
Now, my shared hosting give access of SSH so I have installed a new Laravel project. Then copy my edited and added file except vendor from my localhost to Hosting. Then I update the composer and dump-autoload, Now my application is working file.
But I am not sure about the process I did. Is it the right way (I don't think so)? Please let me know what was the problem of directly uploaded file and is there any problem if I use second system for my production app.
There are chances that your route cache is messed up. It is safe to artisan route:clear, artisan cache:clear, and artisan view:clear before uploading your files to ensure that no compiled script left - which usually tied to specific path.
But it is unclear, could you share your stacktrace for your error (and if possible share where your .htaccess file and it's content)?
sorry i can't comment, need higher point. However, by looking at your statement that it works by moving your files (controller, views, public, etc) but not the entire project, i believe clearing caches is the best to try.
As for the deployment of laravel project, there are methods suggested in laravel.io. It is not a good idea to expose your entire laravel files in public folder. Nevertheless, there are many ways to deploy it.
I know it's a little late but you need to either:
1. Make laravel's public folder the root folder of your domain or
2. Make a sub-domain and point the root folder to your projects public folder. The disadvantage with this is that your sessions cannot be connected directly to your main domain's sessions.
I need to install and configure an existing Laravel 4 project.
I tried to do, but when I ran composer update or composer install a lot of issues appear.
I have the database too (with data) so I ran the migration but doesn't work because the console show me an issue about the "table doesn't exist".
Can anyone tell me the complete process to configure the App?.
I mean, what its first, second and so and so because maybe in some step I made a mistake
To install and configure an existing project, you'd typically
Check out its source code
Run composer install
Run php artisan migrate
Check the README for specific instructions on installing 3rd party assets, or any additional steps you'd need to take
If the above creates errors, its either because of something in your environment (installing over an old project?) or some problem with the way the Laravel developer created their project.
To install and configure an existing project, you'd typically check those things first :
You should goto app/config/database.php check file and verify username and password.
After check in Project Folder vendor folder and composer.json file exist then remove it (that remove old configuration now we going to fresh configuration).
Then after back to command prompt and fire command composer update and that download some dependent file download.
Now Run php artisan serve
that tricks work for me last time when I migrate another host.
Carlos, when using an existing DB you'll need to check the migrations table to see which migrations have run successfully. Typically when taking over a laravel project setting up a new db and running the migrations against it is a good idea because you never know what hacks were made to the database outside the migration system. One small change can throw the entire system into a useless state because it's looking for a table or column that doesn't exist or has been modified. If you run the migrations against a bare db you can also figure out which tables were manually created (which could very well be your issue) outside the system and add them in as necessary. Cobbling things together after a previous developer is tedious, hopefully there is decent documentation.
Note that if you are using Git with .gitignore, don't forget to copy .env variables in new location too.