I have a Laravel app on Heroku that I would like to edit a framework file on (Request.php to be specific). But when I push the changes, it seems to get overwritten by the server.
Is this possible?
Thanks!
Laravel framework files are inside vendor folder which are ignored by git. i.e in you .gitignroe file. So any changes you make won't be push to heroku until you removed them from .gitignore. Also, alternating the vendor folder is not a good practice. If you want to overwrite them then don't directly modify them. You can use marcos for this. Look here to know about marcos more, the docs are clear and on point
Response::macro('foo', function($value){
//You custom task
return Response::make($value);
});
Related
I'm trying to configure adminLTE in Laravel project. I have found a way of modifying it, but when I want to modify it, it has to be done in vendor/jeroennoten/laravel.../views/master.blade.php or page.blade.php for basics and if I want to modify menus and navs it has to be done in vendor/jeroennoten/laravel-adminlte/config/adminlte.php
By default in .gitignore is also vendor folder. Now, I'm wondering, how to manage all this with GIT cause I'm changing things in vendor file? What is the recommendation and/or best practice? Try not to change anything in vendor, and make views in resource folder (what looks kind of huge work for adminLTE), or to use i.e. !vendor/jeroennoten in .gitignore, track all changes and update it on gitHub.
Is there any additional things I should do if someone wants to pull the project so he/she can see changes in vendor.
I'm new to this, so if this seems kind of dummy question or there is completely different approach please have understanding.
First case: i've got some script, which i've writed by myself(lets call it requests.js).
Second case: there is a big plugin TinyMCE, which i can install from bower or npm.
In first case as far as i understand, i should save my scripts in resources/assets/js. But where should i call them after this? There are 2 files in assets/js, which were installed with Laravel 5.3: app.js and bootstrap.js. Should i call my scripts in these files and then gulp them into a single one?
In second case i should use some npm or bower package manager. But, what should i do next? Where should i call this installed packages?In assets/js/ - app.js or bootstrap.js? But how, or maybe i shouldn't do it?
It's hard to put bower components in resource/assets/js only, because these components often consist of many files, js/css/others. I just use bower install inside root of the installation, bower_components dir appears and I put it into .gitignore. Anyone who pulls changes, can do bower install.
Going further, I make file, where I create json object with two values, js and css, where I put path to files I need. Then I require it inside gulp.js and I can do whatever I want with these files. Usually concat, minify, copy result to public.
Theres nothing wrong with putting frontend into same server. Maybe you work alone or in the small team, and you don't have time to manage too many things. Common practice I see all around is that people make dir angular inside root and just grab all js/html files inside this dir, and copy them to public inside gulp.
It's opinion based, but I think it is not a good practice to mix front-end and back-end.
Your Proposal
Your public (front-end) files, like bootstrap, you should store them in public/ of the Laravel installation. You can use public/assets/js, etc. The folder resources is not available in your html files (if you mean the folder of your Laravel installation).
Better Approach
A better approach is to separate totally your front-end from back-end. In that case, you need a front-end framework, like AngularJS or Ember.
Why?
You can replace one of them without troubles in the other
You can use your back-end as third party api (https://api.yourdomein.com/v1/...)
No conflicts with blade views and other template formats
Of course, separation of responsibilities
You should install your bower components in your resources/assets/js folder. Then add any of these components to your build process in your gulpfile. This way, you have total control over what gets concatenated and minified and ultimately included in your templates.
I have directory structure which looks like that
Framework folder is from https://github.com/yiisoft/yii
For now, I'm updating framework folder like that.
Created another folder for Yii framework. Pulling every update and then duplicating framework directory into framework folder.
I want to automate this routine work. Is there anyway to update this framework folder from https://github.com/yiisoft/yii with commands like
cd framework
git pull
It might be wrong of course, but I'm newbie to git.
Any suggestions?
Thanks in advance
I think you should use Git Submodules:
It often happens that while working on one project, you need to use another project from within it. Perhaps it’s a library that a third party developed or that you’re developing separately and using in multiple parent projects. A common issue arises in these scenarios: you want to be able to treat the two projects as separate yet still be able to use one from within the other.
...
Git addresses this issue using submodules.
Here's a wiki explaining how to manage it in Yii
Issue: Nest a git repo in a git repo WITHOUT storing the second repo in the hosts master repo. The repos need to be two separate entity's. This way I can easily update a client sites base code (used on multiple sites).
Reason for two repos: I have a base php framework that my projects use. Each client gets their own repo that has the files required for that site. Due to the way git/submodules work I have to keep the "framework" as the master repo with the "clients code" as the submodule. The reason is I MUST have the index.php & .htaccess (part of the framework) in the root. That's fine since my framework is designed to extend as needed. I can just put any client files I need in the "site" folder and store that as a separate repo. The obvious downside is in order to setup the site you have to first install the "framework repo" then install the "client repo". Since these are private this setup is fine. I also liked the benefit of being able to update my framework from another project. Trouble is now any push's I do from that clone include the "client code". Also since I need the same setup for my local test of the framework that submodule gets added back to the main framework repo. I thought well why not just clone the "site" folder that holds the "client code" and add that folder to the ignore list. I have to update each by hand but again thats fine. However torisegit seems to think that its now a subproject (limited support) and I cant even add that folder to the ignore list. So i'm assuming nesting git clones is bad but I could be doing it wrong.
Goal: I need to be able to deploy two repos. My "framework" im sure has to be the base/root repo. Then I need to embed somehow a second "client" repo in a folder inside the base repo. The "client" repo never stores the framework code, just its own code. I want to be able to update and push changes to the "framework code" (its alpha so lots of bug fixes) without it storing anything about the "client code" so I can easly just clone it into a new folder for a new site. Again client code is stored in a single folder one level up from the frameworks root. (See example below). Doing this as a git clone breaks TortoiseGit and possibly git when I try to copy paste a folder and even add it by hand to the ignore file. Adding it as a submodules adds it to the master repo so when I clone it trys to add it.
Final Thoughts: Perhaps subprojects would work but there does not seem to be much support for it and I dont understand how to use it. Im trying to keep it to major tools so that my two main tools TortoiseGit and NetBeans support everything. Perhaps there is a way to not store a submodule in the master repo but I cant find it. Maybe subfolders would work but again there does not seem to be much support for it. Seems like the simplest would be it just ignore the folder but at least TortoiseGit seems to break when I try this but I could be doing it wrong.
Example Folder Layout:
-.git (framework repo)
- system *framework folder
-- foo *framework folder
-- bar *framework folder
- site (root for second repo aka client)
-- .git (client repo)
-- config.php *client file
- index.php *framework file
- .htaccess *framework file
The "system" folder, index.php and .htaccess are part of the PHP framework and are generic to all my sites. The "site" folder holds the second repo that contains the files for that site. The second option is to rewrite my framework so that its stored in its own folder and gets called by a new index.php. However this is a major rewrite with a pathing nightmare do to the way its written. Plus the issue of dealing with the .htaccess file since that has to be in the root. Sure I could copy it but then any changes to that file would not get updated in a pull. But at this point i think its the only way.
Hope this makes sense. I'm out of ideas but really want to get this to work.
You can always just clone the second repository where ever inside the first you like, then add the second's folder to your .gitignore file.
In your example above, you'd just add:
site/
to your .gitignore.
Git Submodules is the best thing I can think of. Check it out here. It's very handy for splitting up code into reusable repos too.
I'm starting to use the Symfony php framework.
Where can I find information about the use of Mercurial in my symfony projects?
There are two things you need to keep in mind:
First: Put an .hgignore file in the root folder of your project. Put the following content in this file:
.project
^cache$
^log$
web/uploads
nbproject
nbproject is only needed if you are working with netbeans.
Second: At the moment there is no mercurial repository for Symfony itself, so you can not use the framework as a subrepository at the moment (BTW: I'm planning to setup one on bitbucket in the next days). So if you are using Symfony with svn:external at the moment you need to put a complete copy in the lib/vendor/symfony folder
Thats it :-)