How to auto import laravel class in vs code [closed] - php

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 1 year ago.
The community reviewed whether to reopen this question 1 year ago and left it closed:
Original close reason(s) were not resolved
Improve this question
I am currently working on laravel project in visual studio code text editor. If i use laravel package classes in the code at that time i want to automatically import that class using any vs code extension. If you know any best extension for this let me know.
For example I am using Schema class in the code then class should automatically imported like use use Illuminate\Support\Facades\Schema;

Use PHP Intelephense extension by Ben Mewburn for auto importing class name and many more feature. Install from vs code editor or check it here

PHP Namespace Resolver extension for VSCode works fine for me.

PHP Intelephense is the best extension for auto import class.

consider checking this out too: https://github.com/phpactor/vscode-phpactor
I use phpactor in my day to day, code intellissense, auto imports, refactoring tools like renaming classes and thus its references, navigation options (ie, move from source to test, mother or whatever), etc

Related

how to use namespace instead of include("file.php") [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
Following is my folder structure
--project
|_____classes
|_____config.php
|_____classes.php
|_____project
|_____index.php
|_____dashboard.php
According to the folder structure, I have all the database configurations in config.php & I have it extended in classes.php and more classes in it.
Now when I use it in the file in dashboard.php in the project folder I have to do something like this includes("../classes/config.php");
I have read the namespace concept in PHP, I have viewed many videos but I am not able to understand the concept that how to use a namespace instead of the include(''); thing.
Can anyone provide me a demo code or source codes .zip file so that I can understand the concept to implement in the project?
Any helps appreciated. Thanks :)
A namespace is not a replacement for include or require.
You can use an autoloading strategy to load classes as required. PSR-4 is a recommended standard for this, and they have an example implementation
If you're using Composer to manage the packages in your project, you can configure it to autoload your classes
Namespace is just a virtual directory system. To use code from another physical file you have to include it, there is no other work around.
just add this line at the top of your page.
use \YOUR\NAMESPACE\HERE;
and, you are good to use that specified namespace now, but still you have to include it.
To add some automation, you can use spl_autoload_register() function to automatically include you files upon class call.

Generating a word file using template with php on Linux Server [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
Please let me know if you know a word file generator for php on Linux server.
I have a template word file and I want to generate a word file according to the template using php from my linux webserver.
As far as I can find on the web, all of these php libraries need Microsoft Word application to install on the server. I need plug-in which doesn't need to install word in the webserver since mine is linux. Please guide me.
Any work around or name of the plug-in would help me. Thanks in advance.
As mentioned in comment you can use You can use https://github.com/PHPOffice/PHPWord It's a PHP library that can create DOCX along with some formatting.
If you are looking for a similar solution you can also visit this link
http://webcheatsheet.com/php/create_word_excel_csv_files_with_php.php

How can I build PHP Extension from PHP Code [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I am looking to convert my PHP library code as a PHP extension. The full library is under a namespace. There are many PHP classes I am using under my library.
Is there any tool which convert the PHP code to .so and .dll PHP extension (with the namespace usage) ?
Writing the code in C or CPP is too much of work.
There is no tool that will automagically convert PHP code to a PHP Extension, but tools like Zephir provide a half-way DSL that can easily be converted from straight PHP and then compiled against Zephir to build a PHP extension... and yes, it does work with namespaces
The Zephir docs are pretty good, and give a decent explanation of how to write code for the Zephir DSL, and there are blog posts like marmelab's that show how to convert a PHP (namespaced) class to an extension using Zephir.
Edit
Since posting this answer, I've also discovered PHP-to-Zephir which claims to be able to convert PHP code to the Zephir DSL, although I haven't tested it in any way

PHP | check which classes / methods don't have tests setup [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I'm using codeigniter / codeigniter-phpunit / phpunit and it's all working great.
I'm currently going through and adding tests for my models and their methods but it's all getting quite big now, especially when new methods are being added to classes that already have tests configured.
Other than TDD (Test Drive Development) as I still have a lot of existing code I need to build tests for, is there a tool that I can use that will scan all my classes/methods and then show which ones do not have a corresponding test written for it?
Then I can slowly work my way through the the classes/methods that have missing tests.
I appreciate this isn't a belt a braces solution as it can't quantify the quality of my existing tests or anything like that, but it would be nice to have a list of methods which are missings tests for a starting point.
Thanks All
R
You want to see your code coverage, You can read about this for phpunit here:
https://phpunit.de/manual/current/en/code-coverage-analysis.html

Stuck on the parse.com getting started guide [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I'm trying to follow the guid on: https://www.parse.com/apps/quickstart#parse_data/php
I complete the composer install, create the composer.json file and install the SDK as described in the guide.
The next step is a mystery to me: "Require the autoload.php file, and initialize Parse:" What does this mean? Do I create a file and put the code in it? What should the file be called? Where should it be located? How to I run it?
The "guide" doesn't explain what I'm actually supposed to do!?
It does, it's the lines of code directly below that.
require 'vendor/autoload.php';
use Parse\ParseClient;
ParseClient::initialize('APPLICATION ID', 'REST API KEY', 'MASTER KEY');
Put it wherever you want, call it whatever you want.
Are you using any other framework? Parse is only the data model, you need something like Laravel or Symphony to put your code together. The next step depends on the framework you choose. In fact, I'm sure there are bridge libraries for those frameworks that do everything for you.
To start though, you can just create an index.php file and add those lines in. This will be enough to let you test the Parse library/service.

Categories